#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll k;
cin>>k;
ll b[k+5];
bool same=true;
for(ll i=0;i<k;i++){
cin>>b[i];
if(i>0){
same&=(b[i]==b[i-1]);
}
}
if(k<=1000){
for(ll i=1;i<=1000;i++){
ll cnt=0;
for(ll j=0;j<k;j++){
ll n=i+j;
bool ok=false;
while(n>0){
if(n%10==b[j]){
ok=true;
break;
}
n/=10;
}
cnt+=(ok==true);
}
if(cnt==k){
cout<<i;
return 0;
}
}
}
if(same==true){
if(1<b[0]&&b[0]<9){
ll ans=b[0];
ll cur=1;
while(cur<k){
cur*=10;
ans*=10;
}
cout<<ans;
}
if(b[0]==0){
ll cur=1;
ll ans=10;
while(cur<k){
cur=cur*10+1;
ans*=10;
}
cout<<ans;
}
if(b[0]==9){
if(k==1){
cout<<9;
return 0;
}
ll ans=89;
ll cur=11;
while(cur<k){
ans*=10;
cur=cur*10+1;
}
cout<<ans;
}
return 0;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
316 KB |
Output is correct |
6 |
Correct |
0 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
312 KB |
Output is correct |
8 |
Correct |
6 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
316 KB |
Output is correct |
14 |
Correct |
8 ms |
320 KB |
Output is correct |
15 |
Correct |
8 ms |
324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Incorrect |
5 ms |
316 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Incorrect |
4 ms |
712 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |