# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
118707 | 2019-06-19T13:08:08 Z | songc | 수열 (BOI14_sequence) | C++14 | 266 ms | 1408 KB |
#include <bits/stdc++.h> #define INF 1234567890123456ll using namespace std; typedef long long LL; int N; int A[20][101010]; LL f(int lv, int k){ LL ans = INF; bool tf=true; for (int i=1; i<=k; i++) if (A[lv][i]) tf = false; if (tf) return 0; if (lv>15) return INF; if (k == 1){ ans = 0; for (int i=1; i<10; i++) if (A[lv][1] & (1<<i)){ ans = ans*10 + i; if (A[lv][1] & 1) ans *= 10, A[lv][1] ^= 1; } if (A[lv][1] & 1) ans = 10; return ans; } for (int i=0; i<10; i++){ for (int j=1; j<=k; j++) A[lv+1][j] = 0; for (int j=1; j<=k; j++) A[lv+1][(i+j-1)/10+1] |= A[lv][j] & ~(1<<((i+j-1)%10)); LL ret = f(lv+1, (i+k-1)/10+1); if (ret == INF) continue; if (ret == 0 && i == 0) ans = min(ans, 10ll); else ans = min(ans, ret*10+i); } return ans; } int main(){ scanf("%d", &N); for (int i=1; i<=N; i++) { scanf("%d", &A[0][i]); A[0][i] = 1 << A[0][i]; } printf("%lld\n", f(0, N)); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Incorrect | 3 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Incorrect | 3 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 31 ms | 512 KB | Output is correct |
3 | Correct | 31 ms | 512 KB | Output is correct |
4 | Correct | 30 ms | 540 KB | Output is correct |
5 | Correct | 30 ms | 512 KB | Output is correct |
6 | Correct | 23 ms | 512 KB | Output is correct |
7 | Correct | 174 ms | 1120 KB | Output is correct |
8 | Correct | 129 ms | 876 KB | Output is correct |
9 | Correct | 254 ms | 1408 KB | Output is correct |
10 | Correct | 266 ms | 1408 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Incorrect | 3 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |