Problem details
https://codeforces.com/contest/1956/problem/A
Problem - A - Codeforces
codeforces.com
Ideas
- The a(1) is the smallest number of all a(k).
- All players of order greater than or equal to a(1) are kicked out.
Answer code (Java)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t, k, q, a;
t = sc.nextInt();
for (int i = 0; i < t; i++) {
k = sc.nextInt();
q = sc.nextInt();
a = 0;
for (int j = 0; j < k; j++) {
if (a == 0) a = sc.nextInt(); // The a(1) is the smallest number of all a(k).
else sc.nextInt();
}
for (int j = 0; j < q; j++) {
System.out.print(Math.min(a - 1, sc.nextInt()) + " "); // All players of order greater than n(i) are kicked out.
}
System.out.println();
}
}
}
'-- 기타 -- > Problem Solve' 카테고리의 다른 글
[Codeforces Round 939] B. Nene and the Card Game (0) | 2024.04.14 |
---|---|
[2024 KAKAO WINTER INTERNSHIP] 가장 많이 받은 선물 (0) | 2024.04.14 |
[Codeforces Round 938] B. Progressive Square (0) | 2024.04.14 |
[Codeforces Round 938] A. Yogurt Sale (0) | 2024.04.14 |
[백준] JAVA11 컴파일 환경 (0) | 2023.11.24 |