//曇り空 のぞいた予感
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int , int> pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 1e5 + 10;
const ll mod = 1e9+7;
#define pb push_back
#define endl '\n'
#define dokme(x) cout << x , exit(0)
#define ms(x , y) memset(x , y , sizeof x)
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}
int n , a[maxn];
bool cnt(int x , int d){
while(x){
if(x%10 == d)return 1;
x /= 10;
}
return 0;
}
ll f(int x){
ll ans = 1;
if(x == 0)return 10;
while(x){
ans *= 10;
x /= 10;
}
return ans;
}
ll solve(int x){
int need[10];
ms(need , 0);
int cur = x;
for(int i = 0 ; i < n ; i ++){
if(!cnt(cur , a[i])){
need[a[i]] = 1;
}
cur++;
if(cur >= 10000)return 1e18;
}
ll ans = 0;
if(need[0]){
for(int i = 1 ; i < 10 ; i ++)if(need[i]){
if(need[0])ans = i*10 , need[0] = 0;
ans = ans * 10 + i;
}
if(ans == 0)ans = 10;
ans = ans * f(x) + x;
}
else{
for(int i = 1 ; i < 10 ; i ++)if(need[i])ans = ans * 10 + i;
ans = ans * f(x) + x;
}
if(ans == 9)dokme(x);
return ans;
}
int32_t main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin >> n;
for(int i = 0 ; i < n ; i ++)
cin >> a[i];
ll ans = 1e18;
for(int i = 0 ; i < 10000 ; i ++)
ans = min(ans , solve(i));
cout << ans;
return(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
45 ms |
204 KB |
Output is correct |
3 |
Correct |
12 ms |
324 KB |
Output is correct |
4 |
Correct |
12 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Incorrect |
10 ms |
316 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
47 ms |
204 KB |
Output is correct |
3 |
Correct |
12 ms |
204 KB |
Output is correct |
4 |
Correct |
12 ms |
328 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Incorrect |
88 ms |
304 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
469 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
46 ms |
208 KB |
Output is correct |
3 |
Correct |
12 ms |
320 KB |
Output is correct |
4 |
Correct |
12 ms |
324 KB |
Output is correct |
5 |
Incorrect |
602 ms |
484 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |