///ITNOG
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
constexpr int MOD = 1e9 + 7, N = 1e7 + 8, M = 1e6, SQ = 600, INF = 1e9 + 8, LGN = 22, mod = 998244353, P = 131113;
bool mark[N][10];
int n;
string a;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
for(int i = 1; i < N; ++ i){
string s = to_string(i);
for (char ch : s){
mark[i][ch-'0'] = true;
}
}
cin >> n;
for (int i = 0; i < N; ++ i){
int x; cin >> x;
a += ((char) x + '0');
}
for (int i = 1; i < N; ++ i){
bool ok = true;
for (int j = 0; j < n; ++ j){
if (!mark[i+j][a[j] - '0']){
ok = false;
}
}
if (ok){
cout << i;
return 0;
}
}
cout << -1;
}
// Yesterday is history
// Tomorrow is a mystery
// but today is a gift
// That is why it is called the present
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
241 ms |
114180 KB |
Output is correct |
2 |
Correct |
238 ms |
114764 KB |
Output is correct |
3 |
Correct |
243 ms |
114676 KB |
Output is correct |
4 |
Correct |
249 ms |
114684 KB |
Output is correct |
5 |
Correct |
235 ms |
114560 KB |
Output is correct |
6 |
Correct |
235 ms |
114872 KB |
Output is correct |
7 |
Correct |
236 ms |
114112 KB |
Output is correct |
8 |
Correct |
239 ms |
114444 KB |
Output is correct |
9 |
Correct |
237 ms |
114868 KB |
Output is correct |
10 |
Correct |
241 ms |
113924 KB |
Output is correct |
11 |
Correct |
235 ms |
113928 KB |
Output is correct |
12 |
Correct |
236 ms |
114176 KB |
Output is correct |
13 |
Correct |
248 ms |
114040 KB |
Output is correct |
14 |
Correct |
250 ms |
113844 KB |
Output is correct |
15 |
Correct |
238 ms |
114452 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
266 ms |
115728 KB |
Output is correct |
2 |
Correct |
239 ms |
114616 KB |
Output is correct |
3 |
Correct |
237 ms |
115068 KB |
Output is correct |
4 |
Correct |
241 ms |
113912 KB |
Output is correct |
5 |
Correct |
235 ms |
114872 KB |
Output is correct |
6 |
Correct |
243 ms |
114048 KB |
Output is correct |
7 |
Correct |
246 ms |
115516 KB |
Output is correct |
8 |
Correct |
244 ms |
114616 KB |
Output is correct |
9 |
Correct |
237 ms |
114872 KB |
Output is correct |
10 |
Correct |
239 ms |
113848 KB |
Output is correct |
11 |
Execution timed out |
1073 ms |
115444 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
259 ms |
114524 KB |
Output is correct |
2 |
Execution timed out |
1100 ms |
115452 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
242 ms |
114364 KB |
Output is correct |
2 |
Correct |
234 ms |
114192 KB |
Output is correct |
3 |
Correct |
251 ms |
114600 KB |
Output is correct |
4 |
Correct |
248 ms |
113648 KB |
Output is correct |
5 |
Execution timed out |
1068 ms |
114720 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |