이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |