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;
const long long inf = 1e18 + 10;
const int inf1 = 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
const int maxn = -1;
set<int> digits(int x) {
set<int> s;
while(x != 0) {
s.insert(x%10);
x/= 10;
}
return s;
}
void solve() {
int k;
cin >> k;
vector<int> b(k);
for(int i = 0; i < k; i++) {
cin >> b[i];
}
for(int n = 1; n <= 1000; n++) {
bool ok = true;
for(int j = 0; j < k; j++) {
if(digits(n+j).count(b[j]) == 0) {
ok = false;
break;
}
}
if(ok) {
cout << n << endl; break;
}
}
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(0);
#ifndef ONLINE_JUDGE
#endif
int tt = 1;
// cin >> tt;
while(tt--) {
solve();
}
}
# | 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... |