# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
552601 | 2022-04-23T11:53:15 Z | QwertyPi | Bali Sculptures (APIO15_sculpture) | C++14 | 80 ms | 95008 KB |
#include <bits/stdc++.h> #define int long long #define INF (1LL << 60) using namespace std; const int N = 2001; int dp[N][N], dp2[N]; int s[N], A[N]; vector<int> vals[N][N]; typedef uint32_t uint; bool valid[N][N]; int n, a, b; bool check(int mask){ for(int i = 0; i < n; i++){ for(int j = i; j < n; j++){ int v = s[j + 1] - s[i]; valid[i][j] = (v | mask) == mask; } } if(n < -100){ fill(dp2 + 1, dp2 + n + 1, INF); for(int i = 0; i < n; i++){ for(int j = 0; j <= i; j++){ dp2[i + 1] = min(dp2[i + 1], dp2[j] + valid[j][i]); } } return dp2[n] <= b; }else{ for(int i = 0; i <= n; i++){ for(int j = 0; j <= n; j++){ dp[i][j] = false; } } dp[0][0] = true; for(int tr = 0; tr < n; tr++){ for(int i = 0; i < n; i++){ for(int j = i; j < n; j++){ dp[tr + 1][j + 1] |= dp[tr][i] & valid[i][j]; } } } bool ans = false; for(int i = a; i <= b; i++){ ans |= dp[i][n]; } return ans; } } int32_t main(){ cin >> n >> a >> b; vals[0][0].push_back(0); for(int i = 1; i <= n; i++) cin >> A[i], s[i] = s[i - 1] + A[i]; uint mask = 0; for(int j = 60; j >= 0; j--){ if(!check(mask + (1LL << j) - 1)){ mask += 1LL << j; } } cout << mask << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 94292 KB | Output is correct |
2 | Correct | 43 ms | 94260 KB | Output is correct |
3 | Correct | 45 ms | 94272 KB | Output is correct |
4 | Correct | 48 ms | 94368 KB | Output is correct |
5 | Correct | 46 ms | 94292 KB | Output is correct |
6 | Correct | 47 ms | 94308 KB | Output is correct |
7 | Correct | 53 ms | 94380 KB | Output is correct |
8 | Correct | 51 ms | 94348 KB | Output is correct |
9 | Correct | 44 ms | 94420 KB | Output is correct |
10 | Correct | 44 ms | 94412 KB | Output is correct |
11 | Correct | 45 ms | 94416 KB | Output is correct |
12 | Correct | 46 ms | 94324 KB | Output is correct |
13 | Correct | 45 ms | 94412 KB | Output is correct |
14 | Correct | 46 ms | 94284 KB | Output is correct |
15 | Correct | 48 ms | 94288 KB | Output is correct |
16 | Correct | 47 ms | 94320 KB | Output is correct |
17 | Correct | 46 ms | 94300 KB | Output is correct |
18 | Correct | 43 ms | 94316 KB | Output is correct |
19 | Correct | 44 ms | 94524 KB | Output is correct |
20 | Correct | 45 ms | 94376 KB | Output is correct |
21 | Correct | 47 ms | 94420 KB | Output is correct |
22 | Correct | 46 ms | 94360 KB | Output is correct |
23 | Correct | 53 ms | 94400 KB | Output is correct |
24 | Correct | 47 ms | 94412 KB | Output is correct |
25 | Correct | 43 ms | 94420 KB | Output is correct |
26 | Correct | 47 ms | 94364 KB | Output is correct |
27 | Correct | 45 ms | 94272 KB | Output is correct |
28 | Correct | 46 ms | 94316 KB | Output is correct |
29 | Correct | 47 ms | 94324 KB | Output is correct |
30 | Correct | 47 ms | 94412 KB | Output is correct |
31 | Correct | 54 ms | 94376 KB | Output is correct |
32 | Incorrect | 49 ms | 94500 KB | Output isn't correct |
33 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 46 ms | 94352 KB | Output is correct |
2 | Correct | 45 ms | 94376 KB | Output is correct |
3 | Correct | 54 ms | 94284 KB | Output is correct |
4 | Correct | 46 ms | 94304 KB | Output is correct |
5 | Correct | 48 ms | 94292 KB | Output is correct |
6 | Correct | 45 ms | 94376 KB | Output is correct |
7 | Correct | 52 ms | 94412 KB | Output is correct |
8 | Correct | 56 ms | 94336 KB | Output is correct |
9 | Correct | 46 ms | 94412 KB | Output is correct |
10 | Correct | 52 ms | 94356 KB | Output is correct |
11 | Correct | 46 ms | 94408 KB | Output is correct |
12 | Correct | 44 ms | 94396 KB | Output is correct |
13 | Correct | 47 ms | 94420 KB | Output is correct |
14 | Correct | 45 ms | 94292 KB | Output is correct |
15 | Correct | 46 ms | 94416 KB | Output is correct |
16 | Correct | 50 ms | 94304 KB | Output is correct |
17 | Correct | 46 ms | 94332 KB | Output is correct |
18 | Correct | 45 ms | 94336 KB | Output is correct |
19 | Correct | 45 ms | 94376 KB | Output is correct |
20 | Correct | 45 ms | 94388 KB | Output is correct |
21 | Correct | 45 ms | 94348 KB | Output is correct |
22 | Correct | 45 ms | 94340 KB | Output is correct |
23 | Correct | 47 ms | 94428 KB | Output is correct |
24 | Correct | 48 ms | 94396 KB | Output is correct |
25 | Correct | 46 ms | 94420 KB | Output is correct |
26 | Correct | 45 ms | 94356 KB | Output is correct |
27 | Correct | 44 ms | 94448 KB | Output is correct |
28 | Correct | 46 ms | 94424 KB | Output is correct |
29 | Correct | 46 ms | 94464 KB | Output is correct |
30 | Correct | 48 ms | 94540 KB | Output is correct |
31 | Correct | 49 ms | 94624 KB | Output is correct |
32 | Correct | 48 ms | 94628 KB | Output is correct |
33 | Correct | 47 ms | 94564 KB | Output is correct |
34 | Correct | 48 ms | 94640 KB | Output is correct |
35 | Correct | 47 ms | 94540 KB | Output is correct |
36 | Correct | 47 ms | 94528 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 94316 KB | Output is correct |
2 | Correct | 45 ms | 94292 KB | Output is correct |
3 | Correct | 46 ms | 94344 KB | Output is correct |
4 | Correct | 51 ms | 94304 KB | Output is correct |
5 | Correct | 52 ms | 94396 KB | Output is correct |
6 | Correct | 46 ms | 94336 KB | Output is correct |
7 | Correct | 47 ms | 94356 KB | Output is correct |
8 | Correct | 53 ms | 94420 KB | Output is correct |
9 | Correct | 47 ms | 94412 KB | Output is correct |
10 | Correct | 46 ms | 94428 KB | Output is correct |
11 | Correct | 56 ms | 94436 KB | Output is correct |
12 | Correct | 45 ms | 94348 KB | Output is correct |
13 | Correct | 54 ms | 94400 KB | Output is correct |
14 | Correct | 45 ms | 94432 KB | Output is correct |
15 | Correct | 50 ms | 94484 KB | Output is correct |
16 | Correct | 47 ms | 94456 KB | Output is correct |
17 | Correct | 46 ms | 94536 KB | Output is correct |
18 | Correct | 51 ms | 94552 KB | Output is correct |
19 | Correct | 49 ms | 94556 KB | Output is correct |
20 | Correct | 56 ms | 94572 KB | Output is correct |
21 | Correct | 54 ms | 94556 KB | Output is correct |
22 | Correct | 58 ms | 94548 KB | Output is correct |
23 | Correct | 52 ms | 94540 KB | Output is correct |
24 | Correct | 49 ms | 94536 KB | Output is correct |
25 | Correct | 55 ms | 94668 KB | Output is correct |
26 | Correct | 62 ms | 94804 KB | Output is correct |
27 | Correct | 66 ms | 94856 KB | Output is correct |
28 | Correct | 67 ms | 94972 KB | Output is correct |
29 | Correct | 72 ms | 95008 KB | Output is correct |
30 | Correct | 74 ms | 94996 KB | Output is correct |
31 | Correct | 80 ms | 94928 KB | Output is correct |
32 | Correct | 79 ms | 95008 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 94272 KB | Output is correct |
2 | Correct | 47 ms | 94284 KB | Output is correct |
3 | Correct | 48 ms | 94348 KB | Output is correct |
4 | Correct | 44 ms | 94284 KB | Output is correct |
5 | Correct | 50 ms | 94412 KB | Output is correct |
6 | Correct | 50 ms | 94320 KB | Output is correct |
7 | Correct | 57 ms | 94404 KB | Output is correct |
8 | Correct | 57 ms | 94400 KB | Output is correct |
9 | Correct | 50 ms | 94420 KB | Output is correct |
10 | Correct | 46 ms | 94412 KB | Output is correct |
11 | Correct | 46 ms | 94332 KB | Output is correct |
12 | Correct | 46 ms | 94360 KB | Output is correct |
13 | Correct | 46 ms | 94380 KB | Output is correct |
14 | Correct | 45 ms | 94284 KB | Output is correct |
15 | Correct | 47 ms | 94284 KB | Output is correct |
16 | Correct | 45 ms | 94360 KB | Output is correct |
17 | Correct | 49 ms | 94320 KB | Output is correct |
18 | Correct | 47 ms | 94408 KB | Output is correct |
19 | Correct | 54 ms | 94356 KB | Output is correct |
20 | Correct | 44 ms | 94312 KB | Output is correct |
21 | Correct | 51 ms | 94368 KB | Output is correct |
22 | Correct | 46 ms | 94436 KB | Output is correct |
23 | Correct | 47 ms | 94496 KB | Output is correct |
24 | Correct | 54 ms | 94360 KB | Output is correct |
25 | Correct | 46 ms | 94328 KB | Output is correct |
26 | Correct | 52 ms | 94428 KB | Output is correct |
27 | Correct | 54 ms | 94296 KB | Output is correct |
28 | Correct | 52 ms | 94308 KB | Output is correct |
29 | Correct | 48 ms | 94408 KB | Output is correct |
30 | Correct | 48 ms | 94356 KB | Output is correct |
31 | Correct | 45 ms | 94408 KB | Output is correct |
32 | Incorrect | 47 ms | 94416 KB | Output isn't correct |
33 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 94368 KB | Output is correct |
2 | Correct | 48 ms | 94380 KB | Output is correct |
3 | Correct | 47 ms | 94320 KB | Output is correct |
4 | Correct | 47 ms | 94288 KB | Output is correct |
5 | Correct | 51 ms | 94388 KB | Output is correct |
6 | Correct | 55 ms | 94408 KB | Output is correct |
7 | Correct | 50 ms | 94380 KB | Output is correct |
8 | Correct | 44 ms | 94412 KB | Output is correct |
9 | Correct | 44 ms | 94420 KB | Output is correct |
10 | Correct | 45 ms | 94352 KB | Output is correct |
11 | Correct | 50 ms | 94456 KB | Output is correct |
12 | Correct | 53 ms | 94412 KB | Output is correct |
13 | Correct | 45 ms | 94380 KB | Output is correct |
14 | Correct | 46 ms | 94304 KB | Output is correct |
15 | Correct | 44 ms | 94336 KB | Output is correct |
16 | Correct | 47 ms | 94420 KB | Output is correct |
17 | Correct | 46 ms | 94392 KB | Output is correct |
18 | Correct | 50 ms | 94444 KB | Output is correct |
19 | Incorrect | 49 ms | 94452 KB | Output isn't correct |
20 | Halted | 0 ms | 0 KB | - |