# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
249016 | 2020-07-14T05:26:27 Z | SamAnd | Bali Sculptures (APIO15_sculpture) | C++17 | 187 ms | 504 KB |
#include <bits/stdc++.h> using namespace std; #define m_p make_pair #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define fi first #define se second typedef long long ll; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); mt19937 rnf(2106); const int N4 = 102, N5 = 2002, INF = 1000006; int n, ul, ur; int a[N5]; void ka() { scanf("%d%d%d", &n, &ul, &ur); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); } void solv4() { bool dp[N4][N4]; ll ans = 0; for (int i = 50; i >= 0; --i) { memset(dp, false, sizeof dp); dp[0][0] = true; for (int j = 1; j <= n; ++j) { ll s = 0; for (int k = j; k >= 1; --k) { s += a[k]; if (((ans >> i) & (s >> i)) != (s >> i)) continue; for (int q = 0; q <= n; ++q) { if (dp[k - 1][q]) dp[j][q + 1] = true; } } } bool z = false; for (int q = ul; q <= ur; ++q) { if (dp[n][q]) { z = true; break; } } if (!z) { ans |= (1LL << i); } } printf("%lld\n", ans); } void solv5() { int dp[N5]; ll ans = 0; for (int i = 50; i >= 0; --i) { for (int j = 1; j <= n; ++j) { dp[j] = INF; ll s = 0; for (int k = j; k >= 1; --k) { s += a[k]; if (((ans >> i) & (s >> i)) != (s >> i)) continue; dp[j] = min(dp[j], dp[k - 1] + 1); } } if (dp[n] > ur) { ans |= (1LL << i); } } printf("%lld\n", ans); } int main() { #ifdef SOMETHING freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #endif // SOMETHING ka(); if (ul == 1) solv5(); else solv4(); return 0; } //while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 0 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 0 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 0 ms | 384 KB | Output is correct |
28 | Correct | 0 ms | 384 KB | Output is correct |
29 | Correct | 0 ms | 384 KB | Output is correct |
30 | Correct | 0 ms | 384 KB | Output is correct |
31 | Correct | 0 ms | 256 KB | Output is correct |
32 | Correct | 0 ms | 384 KB | Output is correct |
33 | Correct | 0 ms | 384 KB | Output is correct |
34 | Correct | 0 ms | 384 KB | Output is correct |
35 | Correct | 0 ms | 256 KB | Output is correct |
36 | Correct | 0 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 0 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 384 KB | Output is correct |
19 | Correct | 0 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 0 ms | 384 KB | Output is correct |
28 | Correct | 0 ms | 384 KB | Output is correct |
29 | Correct | 0 ms | 384 KB | Output is correct |
30 | Correct | 0 ms | 384 KB | Output is correct |
31 | Correct | 1 ms | 384 KB | Output is correct |
32 | Correct | 1 ms | 384 KB | Output is correct |
33 | Correct | 1 ms | 384 KB | Output is correct |
34 | Correct | 0 ms | 384 KB | Output is correct |
35 | Correct | 1 ms | 384 KB | Output is correct |
36 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 0 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 0 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 0 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 0 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
31 | Correct | 1 ms | 384 KB | Output is correct |
32 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 0 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 0 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 0 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 0 ms | 384 KB | Output is correct |
28 | Correct | 0 ms | 384 KB | Output is correct |
29 | Correct | 0 ms | 384 KB | Output is correct |
30 | Correct | 0 ms | 384 KB | Output is correct |
31 | Correct | 0 ms | 384 KB | Output is correct |
32 | Correct | 0 ms | 384 KB | Output is correct |
33 | Correct | 0 ms | 384 KB | Output is correct |
34 | Correct | 0 ms | 384 KB | Output is correct |
35 | Correct | 0 ms | 384 KB | Output is correct |
36 | Correct | 0 ms | 384 KB | Output is correct |
37 | Correct | 0 ms | 384 KB | Output is correct |
38 | Correct | 0 ms | 384 KB | Output is correct |
39 | Correct | 0 ms | 384 KB | Output is correct |
40 | Correct | 1 ms | 384 KB | Output is correct |
41 | Correct | 1 ms | 384 KB | Output is correct |
42 | Correct | 1 ms | 384 KB | Output is correct |
43 | Correct | 0 ms | 384 KB | Output is correct |
44 | Correct | 1 ms | 384 KB | Output is correct |
45 | Correct | 1 ms | 384 KB | Output is correct |
46 | Correct | 0 ms | 384 KB | Output is correct |
47 | Correct | 1 ms | 384 KB | Output is correct |
48 | Correct | 1 ms | 384 KB | Output is correct |
49 | Correct | 1 ms | 384 KB | Output is correct |
50 | Correct | 1 ms | 384 KB | Output is correct |
51 | Correct | 1 ms | 384 KB | Output is correct |
52 | Correct | 1 ms | 384 KB | Output is correct |
53 | Correct | 1 ms | 384 KB | Output is correct |
54 | Correct | 1 ms | 384 KB | Output is correct |
55 | Correct | 1 ms | 384 KB | Output is correct |
56 | Correct | 0 ms | 384 KB | Output is correct |
57 | Correct | 1 ms | 384 KB | Output is correct |
58 | Correct | 1 ms | 384 KB | Output is correct |
59 | Correct | 1 ms | 384 KB | Output is correct |
60 | Correct | 1 ms | 384 KB | Output is correct |
61 | Correct | 1 ms | 384 KB | Output is correct |
62 | Correct | 1 ms | 384 KB | Output is correct |
63 | Correct | 1 ms | 384 KB | Output is correct |
64 | Correct | 19 ms | 384 KB | Output is correct |
65 | Correct | 2 ms | 384 KB | Output is correct |
66 | Correct | 4 ms | 384 KB | Output is correct |
67 | Correct | 5 ms | 384 KB | Output is correct |
68 | Correct | 9 ms | 384 KB | Output is correct |
69 | Correct | 10 ms | 256 KB | Output is correct |
70 | Correct | 10 ms | 384 KB | Output is correct |
71 | Correct | 11 ms | 384 KB | Output is correct |
72 | Correct | 12 ms | 384 KB | Output is correct |
73 | Correct | 12 ms | 384 KB | Output is correct |
74 | Correct | 13 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 0 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 0 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 384 KB | Output is correct |
19 | Correct | 0 ms | 384 KB | Output is correct |
20 | Correct | 0 ms | 384 KB | Output is correct |
21 | Correct | 0 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 0 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 0 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
31 | Correct | 1 ms | 384 KB | Output is correct |
32 | Correct | 1 ms | 384 KB | Output is correct |
33 | Correct | 1 ms | 384 KB | Output is correct |
34 | Correct | 1 ms | 384 KB | Output is correct |
35 | Correct | 1 ms | 384 KB | Output is correct |
36 | Correct | 1 ms | 384 KB | Output is correct |
37 | Correct | 1 ms | 384 KB | Output is correct |
38 | Correct | 1 ms | 384 KB | Output is correct |
39 | Correct | 1 ms | 384 KB | Output is correct |
40 | Correct | 1 ms | 384 KB | Output is correct |
41 | Correct | 1 ms | 384 KB | Output is correct |
42 | Correct | 1 ms | 384 KB | Output is correct |
43 | Correct | 1 ms | 384 KB | Output is correct |
44 | Correct | 1 ms | 384 KB | Output is correct |
45 | Correct | 1 ms | 384 KB | Output is correct |
46 | Correct | 1 ms | 384 KB | Output is correct |
47 | Correct | 1 ms | 384 KB | Output is correct |
48 | Correct | 1 ms | 384 KB | Output is correct |
49 | Correct | 1 ms | 384 KB | Output is correct |
50 | Correct | 1 ms | 384 KB | Output is correct |
51 | Correct | 1 ms | 384 KB | Output is correct |
52 | Correct | 23 ms | 384 KB | Output is correct |
53 | Correct | 27 ms | 384 KB | Output is correct |
54 | Correct | 47 ms | 384 KB | Output is correct |
55 | Correct | 46 ms | 384 KB | Output is correct |
56 | Correct | 171 ms | 504 KB | Output is correct |
57 | Correct | 166 ms | 384 KB | Output is correct |
58 | Correct | 162 ms | 396 KB | Output is correct |
59 | Correct | 161 ms | 504 KB | Output is correct |
60 | Correct | 176 ms | 504 KB | Output is correct |
61 | Correct | 1 ms | 384 KB | Output is correct |
62 | Correct | 25 ms | 384 KB | Output is correct |
63 | Correct | 47 ms | 384 KB | Output is correct |
64 | Correct | 44 ms | 384 KB | Output is correct |
65 | Correct | 85 ms | 504 KB | Output is correct |
66 | Correct | 126 ms | 384 KB | Output is correct |
67 | Correct | 166 ms | 384 KB | Output is correct |
68 | Correct | 187 ms | 384 KB | Output is correct |
69 | Correct | 163 ms | 504 KB | Output is correct |