Submission #135766

# Submission time Handle Problem Language Result Execution time Memory
135766 2019-07-24T10:44:34 Z tdwn Sequence (BOI14_sequence) C++17
0 / 100
2 ms 380 KB
#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
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 380 KB Output isn't correct
3 Halted 0 ms 0 KB -