#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, a[N];
bool mark[N][11], sm = true;
int main() {
ios:: sync_with_stdio(0), cin.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] ^ a[0]) sm = false;
}
if (sm) {
int l = 1, r = 1;
while (true) {
if (r - l == n) return cout << l << '\n', 0;
if (!mark[r][a[0]]) l = r + 1;
r++;
}
return 0;
}
for (int w = 1; w <= 1000000; w++) {
string s = to_string(w);
for (auto e : s)
mark[w][e - '0'] = true;
}
for (int w = 1; w <= 1000000; w++) {
int cnt = w;
bool flag = true;
for (int i = 0; i < n; i++) {
if (i) cnt++;
if (!mark[cnt][a[i]]) {
flag = false;
break;
}
}
if (flag) {
cout << w << '\n';
return 0;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
12892 KB |
Output is correct |
2 |
Correct |
15 ms |
12940 KB |
Output is correct |
3 |
Correct |
16 ms |
12892 KB |
Output is correct |
4 |
Correct |
16 ms |
12752 KB |
Output is correct |
5 |
Correct |
19 ms |
12944 KB |
Output is correct |
6 |
Correct |
16 ms |
12892 KB |
Output is correct |
7 |
Correct |
18 ms |
12892 KB |
Output is correct |
8 |
Correct |
16 ms |
12892 KB |
Output is correct |
9 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
12892 KB |
Output is correct |
2 |
Correct |
16 ms |
12892 KB |
Output is correct |
3 |
Correct |
16 ms |
12956 KB |
Output is correct |
4 |
Correct |
15 ms |
12940 KB |
Output is correct |
5 |
Correct |
16 ms |
12892 KB |
Output is correct |
6 |
Correct |
16 ms |
12892 KB |
Output is correct |
7 |
Correct |
16 ms |
12892 KB |
Output is correct |
8 |
Correct |
16 ms |
12952 KB |
Output is correct |
9 |
Correct |
16 ms |
12892 KB |
Output is correct |
10 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
12892 KB |
Output is correct |
2 |
Correct |
19 ms |
12880 KB |
Output is correct |
3 |
Correct |
20 ms |
13148 KB |
Output is correct |
4 |
Correct |
15 ms |
12888 KB |
Output is correct |
5 |
Incorrect |
20 ms |
13280 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |