Submission #398871

#TimeUsernameProblemLanguageResultExecution timeMemory
398871faresbasbsSequence (BOI14_sequence)C++14
0 / 100
1 ms208 KiB
#include <bits/stdc++.h>
using namespace std;
int n,arr[1001];

int ok(int a , int b){
	while(a){
		if(a%10 == b){
			return true;
		}
		a /= 10;
	}
	return false;
}

bool ok2(int val){
	int num = val;
	for(int i = 0 ; i < n ; i += 1){
		if(!ok(num,arr[i])){
			return 0;
		}
		num += 1;
	}
	return 1;
}

int main(){
	cin >> n;
	for(int i = 0 ; i < n ; i += 1){
		cin >> arr[i];
	}
	int val = max(arr[0],1);
	while(true){
		if(arr[0] == 9){
			int v2 = 0 , vv = val;
			while(vv){
				v2 = (10*v2+8);
				vv /= 10;
			}
			v2 += 1;
			if(ok2(v2)){
				cout << v2 << endl;
				return 0;
			}
		}
		if(ok2(val)){
			cout << val << endl;
			return 0;
		}
		val *= 10;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...