답안 #421877

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
421877 2021-06-09T13:10:46 Z MetalPower 수열 (BOI14_sequence) C++14
0 / 100
1000 ms 460 KB
#include <bits/stdc++.h>
using namespace std;

const int MX = 1e5 + 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 = 9; j >= 0; j--){
			if(vis[j]){
				ans = (ans << 3) + (ans << 1);
				ans += j;
			}
		}
		if(vis[0] == 1 && ans == 0) ans = 10;
		long long sum = 1;
		while(sum <= N) sum = (sum << 3) + (sum << 1);
		ans = ans * sum + N;
		chmin(mn, ans);
	}

	cout << mn << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 324 KB Output is correct
2 Correct 345 ms 308 KB Output is correct
3 Correct 87 ms 204 KB Output is correct
4 Correct 90 ms 204 KB Output is correct
5 Correct 9 ms 320 KB Output is correct
6 Correct 9 ms 204 KB Output is correct
7 Incorrect 58 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 316 KB Output is correct
2 Correct 345 ms 296 KB Output is correct
3 Correct 87 ms 204 KB Output is correct
4 Correct 88 ms 296 KB Output is correct
5 Correct 9 ms 204 KB Output is correct
6 Correct 9 ms 316 KB Output is correct
7 Incorrect 545 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 204 KB Output is correct
2 Execution timed out 1094 ms 332 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 204 KB Output is correct
2 Correct 346 ms 300 KB Output is correct
3 Correct 96 ms 308 KB Output is correct
4 Correct 88 ms 300 KB Output is correct
5 Execution timed out 1089 ms 460 KB Time limit exceeded
6 Halted 0 ms 0 KB -