Skip to content

Commit f5b01c6

Browse files
Maria Breaks the Self-isolation
1 parent 41f2477 commit f5b01c6

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

1358/B/Main.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import java.util.Arrays;
2+
import java.util.Scanner;
3+
4+
public class Main {
5+
public static void main(String[] args) {
6+
Scanner sc = new Scanner(System.in);
7+
8+
int t = sc.nextInt();
9+
for (int tc = 0; tc < t; ++tc) {
10+
int n = sc.nextInt();
11+
int[] a = new int[n];
12+
for (int i = 0; i < a.length; ++i) {
13+
a[i] = sc.nextInt();
14+
}
15+
16+
System.out.println(solve(a));
17+
}
18+
19+
sc.close();
20+
}
21+
22+
static int solve(int[] a) {
23+
a = Arrays.stream(a).boxed().sorted().mapToInt(x -> x).toArray();
24+
25+
for (int i = a.length - 1; i >= 0; --i) {
26+
if (a[i] <= i + 1) {
27+
return i + 2;
28+
}
29+
}
30+
31+
return 1;
32+
}
33+
}

0 commit comments

Comments
 (0)