Skip to content

Commit ce11309

Browse files
committed
fix(codeforces/2108F): update input and source files
1 parent 2af9bcb commit ce11309

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

codeforces/2108F/1.in

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1-
1
1+
8
22
2
33
1 2
4+
4
5+
2 1 0 0
6+
10
7+
5 9 3 7 1 5 1 5 4 3
8+
10
9+
1 1 1 1 1 1 1 1 1 1
10+
10
11+
3 2 1 0 3 2 1 0 3 2
12+
5
13+
5 2 0 5 5
14+
1
15+
1000000000
16+
7
17+
4 0 1 0 2 7 7

codeforces/2108F/src/Main.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import java.io.*;
2+
import java.util.HashSet;
3+
import java.util.Set;
24
import java.util.StringTokenizer;
35

46
public class Main {
@@ -8,7 +10,7 @@ public class Main {
810

911
int[] a;
1012
int n;
11-
int mex;
13+
int maxMEX;
1214

1315
Main() {
1416
in = new BufferedReader(new InputStreamReader(System.in));
@@ -26,9 +28,9 @@ void solve() throws IOException {
2628
}
2729
int[] p = new int[n];
2830
boolean[] used = new boolean[n];
29-
mex = 0;
31+
maxMEX = 0;
3032
permutation(p, used, 0);
31-
out.println(mex);
33+
out.println(maxMEX);
3234
}
3335
}
3436

@@ -63,12 +65,18 @@ void permutation(int[] p, boolean[] used, int cur) {
6365
}
6466

6567
if (nonDecreasing) {
66-
int sum = 0;
68+
Set<Integer> set = new HashSet<>();
6769
for (int i = 0; i < n; i++) {
68-
sum += b[i];
70+
set.add(b[i]);
6971
}
70-
if (sum > mex) {
71-
mex = sum;
72+
int mex;
73+
for (mex = 1; ; mex++) {
74+
if (!set.contains(mex)) {
75+
break;
76+
}
77+
}
78+
if (mex > maxMEX) {
79+
maxMEX = mex;
7280
}
7381
}
7482
} else {

0 commit comments

Comments
 (0)