#include <iostream>
using namespace std;
int N, A[100001], ans = 0;
bool same = 1;
int main()
{
cin >> N;
for (int i = 0; i < N; i++)
{
cin >> A[i];
if (i) same |= (A[i] == A[i - 1]);
}
if (!same)
{
for (int i = 1; i <= 1000; i++)
{
for (int j = 0; j < N; j++)
{
int c = i + j;
bool exist = 0;
while (c) {exist |= (A[j] == c % 10); c /= 10;}
if (!exist) {break;}
else if (j == N - 1) {ans = i;}
}
if (ans) break;
}
}
else
{
ans = A[0];
if (A[0] == 9)
{
int cnt = 1;
while (cnt < N) {cnt *= 10; cnt++; ans--; ans *= 10; ans += 9;}
}
else if (A[0] == 0)
{
ans = 10;
int cnt = 1;
while (cnt < N) {cnt *= 10; cnt++; ans *= 10;}
}
else
{
N--;
if (!ans) ans = 10;
while (N) {N /= 10; ans *= 10;}
}
}
cout << ans << "\n";
//cerr << "ANS2: " << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
3 ms |
332 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
17 ms |
688 KB |
Output is correct |
8 |
Correct |
9 ms |
500 KB |
Output is correct |
9 |
Correct |
19 ms |
856 KB |
Output is correct |
10 |
Correct |
18 ms |
876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |