This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
int N, A[1 << 18];
bool used[10000009][10];
void init() {
for (int i = 0; i < 10000000; i++) {
int cx = i;
while (cx >= 1) {
used[i][cx % 10] = true;
cx /= 10;
}
}
}
bool check(int pos) {
for (int i = 1; i <= N; i++) {
if (used[pos][A[i]] == false) return false;
pos++;
}
return true;
}
int main() {
cin >> N; init();
for (int i = 1; i <= N; i++) cin >> A[i];
for (int i = 1; i <= 10000000; i++) {
if (check(i) == true) {
cout << i << endl;
return 0;
}
}
cout << "-1" << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |