Submission #421857

# Submission time Handle Problem Language Result Execution time Memory
421857 2021-06-09T13:03:17 Z MetalPower Sequence (BOI14_sequence) C++14
0 / 100
399 ms 296 KB
#include <bits/stdc++.h>
using namespace std;

const int MX = 1e3 + 10, num = 1e5;
int K, arr[MX];

inline int check(int a, const int& b){
	while(a){
		if(a % 10 == b) return true;
		a /= 10;
	}
	return false;
}

inline void chmin(long long& a, long long b){
	if(b < a) a = b;
}

bool vis[10];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

	cin >> K;

	for(int i = 0; i < K; i++) cin >> arr[i];

	long long mn = 1e18;

	for(int N = 1; N < num; N++){
		memset(vis, 0, sizeof vis);
		for(int i = 0; i < K; i++){
			if(!check(N + i, arr[i])) vis[arr[i]] = true;
		}
		long long ans = 0;
		for(int j = 0; j < 10; j++){
			if(vis[j]){
				ans = (ans << 3) + (ans << 1);
				ans += j;
			}
		}
		long long sum = 1;
		while(sum <= N) sum = (sum << 3) + (sum << 1);
		ans = ans * sum + N;
		chmin(mn, ans);
	}

	cout << mn << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 204 KB Output is correct
2 Correct 399 ms 292 KB Output is correct
3 Correct 107 ms 292 KB Output is correct
4 Incorrect 100 ms 288 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 204 KB Output is correct
2 Correct 383 ms 288 KB Output is correct
3 Correct 105 ms 292 KB Output is correct
4 Incorrect 94 ms 296 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 204 KB Output is correct
2 Correct 371 ms 288 KB Output is correct
3 Correct 110 ms 292 KB Output is correct
4 Incorrect 99 ms 292 KB Output isn't correct
5 Halted 0 ms 0 KB -