#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "debug.h"
#else
#define debug(...) 0
#endif
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#define pb push_back
#define i2 array<int, 2>
#define ll long long
const int N = 1e7 + 4;
int k, b[N];
bool f[N][10];
bool have(int x, int d) {
while (x) {
if (x % 10 == d) {
return 1;
}
x /= 10;
}
return 0;
}
void solve() {
cin >> k;
for (int i = 0; i < k; i++) {
cin >> b[i];
}
int n = 1;
while (1) {
bool ok = 1;
if (have(n + k - 1, b[k - 1])) {
for (int j = 0; j < k; j++) {
ok &= f[n + j][b[j]];
if (ok == 0) {
break;
}
}
if (ok) {
cout << n << '\n';
return;
}
}
n++;
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
for (int i = 1; i < N; i++) {
for (int j = 0; j < 10; j++) {
f[i][j] = have(i, j);
}
}
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
919 ms |
99092 KB |
Output is correct |
2 |
Correct |
944 ms |
99208 KB |
Output is correct |
3 |
Correct |
918 ms |
99188 KB |
Output is correct |
4 |
Correct |
919 ms |
99156 KB |
Output is correct |
5 |
Correct |
917 ms |
99036 KB |
Output is correct |
6 |
Correct |
918 ms |
99248 KB |
Output is correct |
7 |
Correct |
926 ms |
99088 KB |
Output is correct |
8 |
Correct |
918 ms |
98984 KB |
Output is correct |
9 |
Correct |
942 ms |
99060 KB |
Output is correct |
10 |
Correct |
914 ms |
99076 KB |
Output is correct |
11 |
Correct |
917 ms |
99084 KB |
Output is correct |
12 |
Correct |
919 ms |
98968 KB |
Output is correct |
13 |
Correct |
916 ms |
99200 KB |
Output is correct |
14 |
Correct |
925 ms |
98940 KB |
Output is correct |
15 |
Correct |
924 ms |
99076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
930 ms |
99196 KB |
Output is correct |
2 |
Correct |
927 ms |
99332 KB |
Output is correct |
3 |
Correct |
942 ms |
99200 KB |
Output is correct |
4 |
Correct |
936 ms |
99072 KB |
Output is correct |
5 |
Correct |
917 ms |
99348 KB |
Output is correct |
6 |
Correct |
933 ms |
99036 KB |
Output is correct |
7 |
Execution timed out |
1004 ms |
99112 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
956 ms |
99056 KB |
Output is correct |
2 |
Correct |
951 ms |
99116 KB |
Output is correct |
3 |
Execution timed out |
1061 ms |
98932 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
923 ms |
99340 KB |
Output is correct |
2 |
Correct |
914 ms |
99188 KB |
Output is correct |
3 |
Correct |
939 ms |
99056 KB |
Output is correct |
4 |
Correct |
941 ms |
99052 KB |
Output is correct |
5 |
Execution timed out |
1051 ms |
99052 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |