# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
270382 | 2020-08-17T14:34:11 Z | BeanZ | Bali Sculptures (APIO15_sculpture) | C++14 | 1000 ms | 640 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 3e6 + 5; ll dp[2005][2005], a[2005], sum[2005]; bool chk(ll now, ll need){ return ((need & now) == now); } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("VietCT.INP", "r")){ freopen("VietCT.INP", "r", stdin); freopen("VietCT.OUT", "w", stdout); } ll n, L, R; cin >> n >> L >> R; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i]; ll ans = 1e18; for (int s = 0; s <= 5000; s++){ for (int i = 0; i <= n; i++){ for (int j = 0; j <= R; j++){ dp[j][i] = 1e18; } } for (int i = 1; i <= n; i++) if (chk(sum[i], s)) dp[1][i] = sum[i]; if (1 >= L) ans = min(ans, dp[1][n]); for (int i = 2; i <= R; i++){ for (int j = 1; j <= n; j++){ for (int k = 0; k < j; k++){ ll cost = dp[i - 1][k] | (sum[j] - sum[k]); if (chk(cost, s)){ if (dp[i][j] > cost){ dp[i][j] = cost; } } } } if (i >= L) ans = min(ans, dp[i][n]); } } cout << ans; } /* 6 1 3 8 1 2 1 5 4 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 17 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 6 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 31 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 3 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 14 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 12 ms | 384 KB | Output is correct |
22 | Correct | 13 ms | 384 KB | Output is correct |
23 | Correct | 11 ms | 384 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 12 ms | 384 KB | Output is correct |
26 | Correct | 23 ms | 384 KB | Output is correct |
27 | Incorrect | 1 ms | 384 KB | Output isn't correct |
28 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 14 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 6 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 6 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 6 ms | 384 KB | Output is correct |
13 | Correct | 26 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 13 ms | 384 KB | Output is correct |
20 | Correct | 4 ms | 384 KB | Output is correct |
21 | Correct | 32 ms | 384 KB | Output is correct |
22 | Correct | 12 ms | 384 KB | Output is correct |
23 | Correct | 23 ms | 384 KB | Output is correct |
24 | Correct | 3 ms | 384 KB | Output is correct |
25 | Correct | 14 ms | 384 KB | Output is correct |
26 | Correct | 21 ms | 384 KB | Output is correct |
27 | Correct | 38 ms | 480 KB | Output is correct |
28 | Correct | 54 ms | 384 KB | Output is correct |
29 | Correct | 62 ms | 504 KB | Output is correct |
30 | Correct | 115 ms | 384 KB | Output is correct |
31 | Correct | 165 ms | 384 KB | Output is correct |
32 | Correct | 158 ms | 384 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 177 ms | 384 KB | Output is correct |
35 | Correct | 143 ms | 384 KB | Output is correct |
36 | Correct | 110 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 14 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 9 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 4 ms | 384 KB | Output is correct |
13 | Correct | 66 ms | 384 KB | Output is correct |
14 | Correct | 35 ms | 384 KB | Output is correct |
15 | Correct | 27 ms | 384 KB | Output is correct |
16 | Correct | 29 ms | 384 KB | Output is correct |
17 | Correct | 134 ms | 384 KB | Output is correct |
18 | Correct | 240 ms | 504 KB | Output is correct |
19 | Correct | 158 ms | 416 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 222 ms | 492 KB | Output is correct |
22 | Correct | 146 ms | 384 KB | Output is correct |
23 | Correct | 95 ms | 384 KB | Output is correct |
24 | Correct | 175 ms | 384 KB | Output is correct |
25 | Correct | 201 ms | 504 KB | Output is correct |
26 | Correct | 472 ms | 504 KB | Output is correct |
27 | Execution timed out | 1097 ms | 640 KB | Time limit exceeded |
28 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 14 ms | 384 KB | Output is correct |
7 | Correct | 7 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 9 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 23 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 6 ms | 384 KB | Output is correct |
19 | Correct | 32 ms | 384 KB | Output is correct |
20 | Correct | 4 ms | 384 KB | Output is correct |
21 | Correct | 19 ms | 384 KB | Output is correct |
22 | Correct | 11 ms | 384 KB | Output is correct |
23 | Correct | 11 ms | 384 KB | Output is correct |
24 | Correct | 3 ms | 384 KB | Output is correct |
25 | Correct | 29 ms | 384 KB | Output is correct |
26 | Correct | 22 ms | 384 KB | Output is correct |
27 | Incorrect | 1 ms | 384 KB | Output isn't correct |
28 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 14 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 27 ms | 384 KB | Output is correct |
14 | Incorrect | 1 ms | 384 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |