#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MX = 1e5 + 10, num = 1e4;
int K, arr[MX];
inline int check(int a, const int& b){
while(a){
if(a % 10 == b) return true;
a /= 10;
}
return false;
}
inline void chmin(long long& a, long long b){
if(b < a) a = b;
}
inline void solve_sub3(){
ll size = K - 1, calc = 1, l = 0;
if(arr[0] == 0){
while(size >= calc){
size -= calc;
calc = (calc << 3) + (calc << 1);
l++;
}
cout << "10";
for(int i = 1; i <= l; i++) cout << "0";
}else if(arr[0] == 9){
while(size >= calc){
size -= calc;
calc = (calc << 3) + (calc << 1);
l++;
}
for(int i = 1; i <= l; i++) cout << "8";
cout << "9";
}else{
while(size){
size /= 10; l++;
}
cout << arr[0];
for(int i = 1; i <= l; i++) cout << "0";
}
cout << '\n';
}
bool vis[10];
int main(){
ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
cin >> K;
bool eq = true;
for(int i = 0; i < K; i++){
cin >> arr[i]; if(arr[i] != arr[0]) eq = false;
}
if(eq){
solve_sub3();
}else{
long long mn = 1e18;
for(int N = 1; N < num; N++){
bool pos = true;
for(int i = 0; i < K; i++){
if(!check(N + i, arr[i])){
pos = false; break;
}
}
if(pos) chmin(mn, (long long) N);
}
cout << mn << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
320 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
6 ms |
672 KB |
Output is correct |
8 |
Correct |
4 ms |
580 KB |
Output is correct |
9 |
Correct |
8 ms |
800 KB |
Output is correct |
10 |
Correct |
8 ms |
736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Incorrect |
4 ms |
460 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |