#include<cstdio>
#include<cstdlib>
#include<algorithm>
int a[100000],n;
void f(int d,int x)
{
if(d==n)
{
printf("%d\n",x);
exit(0);
}
int i,y=x+d;
for(i=1;i<=y;i*=10)if(y/i%10==a[d])break;
if(i<=y)f(d+1,x);
else
{
for(i=1;i<=x;i*=10);
y=a[d]*i+y%i;
f(d+1,y-d);
}
}
int main()
{
int i;
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&a[i]);
f(0,0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1476 KB |
Output is correct |
2 |
Incorrect |
0 ms |
1476 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1476 KB |
Output is correct |
2 |
Incorrect |
0 ms |
1476 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
1476 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1476 KB |
Output is correct |
2 |
Incorrect |
0 ms |
1476 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |