We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 41f2477 commit f5b01c6Copy full SHA for f5b01c6
1358/B/Main.java
@@ -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