# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
398637 | 2021-05-04T16:15:21 Z | mars | 수열 (BOI14_sequence) | C++14 | 159 ms | 1240 KB |
/* * A solution for task Sequence. * Complexity - O(K log K). * * Author: Daumilas Ardickas * Idea: Vytautas Gruslys */ #include <cstdio> #include <vector> using namespace std; long long minN(const vector<int>& A, bool try9 = true) { long long m = 102345678900000L; if (A.size() == 1) { m = 0; for (int a = 1; a <= 9; a++) if (A[0] & (1 << a)) { m = m * 10 + a; if (m == a && A[0] & 1) m *= 10; } if (m == 0 && A[0] & 1) m = 10; return m; } for (int n = 0; n < 9 + try9; n++) { int y = n, a = 0; bool zero = false; vector<int> B; for (int i = 0; i < A.size(); i++) { a |= A[i] & (1023 - (1 << y)); if (A[i] & 1 && y == 0) zero = true; y = (y + 1) % 10; if (!y || i == A.size() - 1) { B.push_back(a); a = 0; } } long long mm = minN(B, n < 9 || A.size() > 2) * 10 + n; if (!mm && zero) mm = 10; m = min(m, mm); } return m; } int main() { int K, d, i; vector<int> A; scanf("%d", &K); for (i = 0; i < K; i++) { scanf("%d", &d); A.push_back(1 << d); } printf ("%lld\n", minN(A)); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 280 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 2 ms | 284 KB | Output is correct |
9 | Correct | 1 ms | 280 KB | Output is correct |
10 | Correct | 2 ms | 208 KB | Output is correct |
11 | Correct | 2 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 2 ms | 204 KB | Output is correct |
15 | Correct | 2 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 284 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 2 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 2 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 2 ms | 204 KB | Output is correct |
12 | Correct | 2 ms | 332 KB | Output is correct |
13 | Correct | 2 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 284 KB | Output is correct |
16 | Correct | 2 ms | 204 KB | Output is correct |
17 | Correct | 2 ms | 284 KB | Output is correct |
18 | Correct | 1 ms | 288 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 2 ms | 204 KB | Output is correct |
21 | Correct | 1 ms | 204 KB | Output is correct |
22 | Correct | 2 ms | 204 KB | Output is correct |
23 | Correct | 2 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 15 ms | 340 KB | Output is correct |
3 | Correct | 16 ms | 436 KB | Output is correct |
4 | Correct | 15 ms | 420 KB | Output is correct |
5 | Correct | 16 ms | 420 KB | Output is correct |
6 | Correct | 13 ms | 364 KB | Output is correct |
7 | Correct | 89 ms | 968 KB | Output is correct |
8 | Correct | 74 ms | 716 KB | Output is correct |
9 | Correct | 125 ms | 1096 KB | Output is correct |
10 | Correct | 127 ms | 1108 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 220 KB | Output is correct |
2 | Correct | 1 ms | 220 KB | Output is correct |
3 | Correct | 1 ms | 220 KB | Output is correct |
4 | Correct | 1 ms | 220 KB | Output is correct |
5 | Correct | 60 ms | 680 KB | Output is correct |
6 | Correct | 1 ms | 280 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 2 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 284 KB | Output is correct |
10 | Correct | 2 ms | 204 KB | Output is correct |
11 | Correct | 134 ms | 1092 KB | Output is correct |
12 | Correct | 132 ms | 1096 KB | Output is correct |
13 | Correct | 1 ms | 208 KB | Output is correct |
14 | Correct | 2 ms | 204 KB | Output is correct |
15 | Correct | 2 ms | 204 KB | Output is correct |
16 | Correct | 2 ms | 284 KB | Output is correct |
17 | Correct | 1 ms | 204 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 2 ms | 204 KB | Output is correct |
20 | Correct | 2 ms | 284 KB | Output is correct |
21 | Correct | 1 ms | 204 KB | Output is correct |
22 | Correct | 1 ms | 204 KB | Output is correct |
23 | Correct | 2 ms | 204 KB | Output is correct |
24 | Correct | 1 ms | 204 KB | Output is correct |
25 | Correct | 2 ms | 204 KB | Output is correct |
26 | Correct | 2 ms | 204 KB | Output is correct |
27 | Correct | 15 ms | 416 KB | Output is correct |
28 | Correct | 15 ms | 416 KB | Output is correct |
29 | Correct | 15 ms | 420 KB | Output is correct |
30 | Correct | 15 ms | 348 KB | Output is correct |
31 | Correct | 11 ms | 348 KB | Output is correct |
32 | Correct | 91 ms | 992 KB | Output is correct |
33 | Correct | 63 ms | 732 KB | Output is correct |
34 | Correct | 128 ms | 1112 KB | Output is correct |
35 | Correct | 159 ms | 1240 KB | Output is correct |
36 | Correct | 98 ms | 984 KB | Output is correct |
37 | Correct | 128 ms | 1112 KB | Output is correct |
38 | Correct | 77 ms | 716 KB | Output is correct |
39 | Correct | 129 ms | 1096 KB | Output is correct |
40 | Correct | 142 ms | 1112 KB | Output is correct |