This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
ll n, arr[maxn];
int main() {
cin>>n;
cin>>arr[1];
ll num = arr[1];
for(int i=2;i<=n;i++) {
num++;
cin>>arr[i];
ll tmp = num;
bool found = false;
while(tmp > 0) {
if((tmp%10) == arr[i]) found = true;
tmp /= 10;
}
if(found) continue;
num--;
tmp = num;
int br = 0;
while(tmp > 0) {
tmp /= 10;
br++;
}
ll nwnum = arr[i];
ll pw = 1LL;
for(int i=0;i<br;i++) {
nwnum *= 10LL;
pw *= 10LL;
}
//cout<<i<<"A: "<<nwnum<<"\n";
nwnum += num + 1;
if(arr[i-1] == 9) {
nwnum -= pw;
}
num = nwnum;
}
cout<<num-n+1<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |