#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++) {
int t = i;
while (t) {
f[i][t % 10] = 1;
t /= 10;
}
}
}
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
581 ms |
98932 KB |
Output is correct |
2 |
Correct |
620 ms |
98980 KB |
Output is correct |
3 |
Correct |
595 ms |
99188 KB |
Output is correct |
4 |
Correct |
580 ms |
98896 KB |
Output is correct |
5 |
Correct |
583 ms |
98900 KB |
Output is correct |
6 |
Correct |
598 ms |
99156 KB |
Output is correct |
7 |
Correct |
584 ms |
99452 KB |
Output is correct |
8 |
Correct |
579 ms |
99052 KB |
Output is correct |
9 |
Correct |
587 ms |
99320 KB |
Output is correct |
10 |
Correct |
640 ms |
98904 KB |
Output is correct |
11 |
Correct |
629 ms |
99112 KB |
Output is correct |
12 |
Correct |
611 ms |
99072 KB |
Output is correct |
13 |
Correct |
591 ms |
99156 KB |
Output is correct |
14 |
Correct |
583 ms |
99496 KB |
Output is correct |
15 |
Correct |
582 ms |
99364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
613 ms |
99044 KB |
Output is correct |
2 |
Correct |
590 ms |
98976 KB |
Output is correct |
3 |
Correct |
595 ms |
99348 KB |
Output is correct |
4 |
Correct |
583 ms |
99488 KB |
Output is correct |
5 |
Correct |
602 ms |
99088 KB |
Output is correct |
6 |
Correct |
583 ms |
99108 KB |
Output is correct |
7 |
Correct |
611 ms |
99548 KB |
Output is correct |
8 |
Correct |
615 ms |
99112 KB |
Output is correct |
9 |
Correct |
612 ms |
98896 KB |
Output is correct |
10 |
Correct |
618 ms |
99156 KB |
Output is correct |
11 |
Execution timed out |
1056 ms |
99288 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
614 ms |
98988 KB |
Output is correct |
2 |
Correct |
595 ms |
99448 KB |
Output is correct |
3 |
Correct |
771 ms |
99112 KB |
Output is correct |
4 |
Correct |
589 ms |
99208 KB |
Output is correct |
5 |
Correct |
766 ms |
99112 KB |
Output is correct |
6 |
Correct |
605 ms |
99048 KB |
Output is correct |
7 |
Correct |
683 ms |
99564 KB |
Output is correct |
8 |
Correct |
747 ms |
99352 KB |
Output is correct |
9 |
Correct |
841 ms |
99112 KB |
Output is correct |
10 |
Correct |
963 ms |
99340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
582 ms |
99360 KB |
Output is correct |
2 |
Correct |
671 ms |
99092 KB |
Output is correct |
3 |
Correct |
631 ms |
99044 KB |
Output is correct |
4 |
Correct |
594 ms |
99036 KB |
Output is correct |
5 |
Runtime error |
840 ms |
200660 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |