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 <bits/stdc++.h>
using namespace std;
bool check(int n, int digit) {
while (n > 0) {
if (n % 10 == digit) {
return true;
}
n /= 10;
}
return false;
}
int main() {
int K;
cin >> K;
vector<int> B(K);
for (int &v : B) {
cin >> v;
}
for (int N = 1; N <= 1000; N++) {
bool Good = true;
for (int i = 0; i < K; i++) {
Good &= check(N + i, B[i]);
}
if (Good) {
cout << N << "\n";
exit(0);
}
}
const int MAX_N = 1e7;
for (int N = 1, j = 1; N < MAX_N; N++) {
j = max(j, N);
while (j < MAX_N && check(j, B[0])) {
j++;
}
if (j - N >= K) {
cout << N << "\n";
exit(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... |