답안 #499091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
499091 2021-12-27T08:19:53 Z cig32 Bali Sculptures (APIO15_sculpture) C++17
71 / 100
1000 ms 712 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 3e5 + 10;
const int MOD = 1e9 + 7;
mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x, int y) {
    int u = uniform_int_distribution<int>(x, y)(rng);
    return u;
}
void solve(int tc) {
    int n, A, B;
    cin >> n >> A >> B;
    int a[n+1];
    for(int i=1; i<=n; i++) cin >> a[i];
    int ps[n+1];
    ps[0] = 0;
    for(int i=1; i<=n; i++) ps[i] = ps[i-1] + a[i];
    int ans = 1e18;
    for(int k=A; k<=B; k++) {
        int msk = 0;
        for(int bit=44; bit>=0; bit--) {
            int dp[k+1][n+1];
            for(int i=0; i<=k; i++) {
                for(int j=0; j<=n; j++) {
                    dp[i][j] = 0;
                }
            }
            for(int i=1; i<=n; i++) dp[1][i] = ((ps[i] & (msk + (1ll << bit))) == 0);
            for(int i=2; i<=k; i++) {
                for(int j=i; j<=n; j++) {
                    for(int l=i-1; l<j; l++) {
                        int wow = ps[j] - ps[l];
                        if((wow & (msk + (1ll << bit))) == 0) {
                            dp[i][j] |= dp[i-1][l];
                        }
                    }
                }
            }
            if(dp[k][n]) {
                msk += (1ll << bit);
            }
        }
        ans = min(ans, (1ll << 45) - 1 - msk);
    }
    cout << ans << endl;
}
int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int t = 1; //cin >> t;
    for(int i=1; i<=t; i++) {
        solve(i);
    }
} 
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 316 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 316 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 0 ms 312 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 312 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 316 KB Output is correct
34 Correct 2 ms 316 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 2 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 312 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 0 ms 312 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 312 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 2 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 320 KB Output is correct
30 Correct 7 ms 316 KB Output is correct
31 Correct 12 ms 312 KB Output is correct
32 Correct 12 ms 204 KB Output is correct
33 Correct 0 ms 204 KB Output is correct
34 Correct 13 ms 312 KB Output is correct
35 Correct 9 ms 204 KB Output is correct
36 Correct 4 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 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 316 KB Output is correct
7 Correct 0 ms 316 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 316 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 7 ms 204 KB Output is correct
18 Correct 12 ms 324 KB Output is correct
19 Correct 12 ms 320 KB Output is correct
20 Correct 0 ms 312 KB Output is correct
21 Correct 12 ms 316 KB Output is correct
22 Correct 9 ms 204 KB Output is correct
23 Correct 4 ms 204 KB Output is correct
24 Correct 13 ms 204 KB Output is correct
25 Correct 7 ms 296 KB Output is correct
26 Correct 45 ms 308 KB Output is correct
27 Correct 280 ms 300 KB Output is correct
28 Correct 869 ms 456 KB Output is correct
29 Correct 853 ms 372 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 300 ms 316 KB Output is correct
32 Correct 570 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 316 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 1 ms 312 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 316 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 2 ms 204 KB Output is correct
35 Correct 1 ms 320 KB Output is correct
36 Correct 2 ms 204 KB Output is correct
37 Correct 2 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 9 ms 204 KB Output is correct
41 Correct 12 ms 312 KB Output is correct
42 Correct 16 ms 316 KB Output is correct
43 Correct 1 ms 320 KB Output is correct
44 Correct 16 ms 320 KB Output is correct
45 Correct 12 ms 204 KB Output is correct
46 Correct 4 ms 204 KB Output is correct
47 Correct 13 ms 204 KB Output is correct
48 Correct 7 ms 316 KB Output is correct
49 Correct 43 ms 324 KB Output is correct
50 Correct 276 ms 320 KB Output is correct
51 Correct 859 ms 440 KB Output is correct
52 Correct 846 ms 364 KB Output is correct
53 Correct 1 ms 316 KB Output is correct
54 Correct 274 ms 316 KB Output is correct
55 Correct 562 ms 472 KB Output is correct
56 Correct 14 ms 204 KB Output is correct
57 Correct 51 ms 316 KB Output is correct
58 Correct 245 ms 328 KB Output is correct
59 Correct 742 ms 452 KB Output is correct
60 Correct 653 ms 444 KB Output is correct
61 Correct 0 ms 204 KB Output is correct
62 Correct 802 ms 448 KB Output is correct
63 Correct 792 ms 712 KB Output is correct
64 Correct 385 ms 336 KB Output is correct
65 Correct 10 ms 204 KB Output is correct
66 Correct 8 ms 204 KB Output is correct
67 Correct 43 ms 324 KB Output is correct
68 Correct 235 ms 324 KB Output is correct
69 Correct 435 ms 336 KB Output is correct
70 Correct 484 ms 476 KB Output is correct
71 Correct 1 ms 204 KB Output is correct
72 Correct 841 ms 448 KB Output is correct
73 Correct 331 ms 464 KB Output is correct
74 Correct 308 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 284 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 320 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 2 ms 204 KB Output is correct
22 Correct 0 ms 320 KB Output is correct
23 Correct 2 ms 204 KB Output is correct
24 Correct 2 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 8 ms 312 KB Output is correct
28 Correct 13 ms 316 KB Output is correct
29 Correct 12 ms 320 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 15 ms 320 KB Output is correct
32 Correct 10 ms 312 KB Output is correct
33 Correct 5 ms 204 KB Output is correct
34 Correct 14 ms 316 KB Output is correct
35 Correct 7 ms 312 KB Output is correct
36 Correct 57 ms 316 KB Output is correct
37 Correct 271 ms 320 KB Output is correct
38 Correct 856 ms 692 KB Output is correct
39 Correct 833 ms 568 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 288 ms 448 KB Output is correct
42 Correct 564 ms 432 KB Output is correct
43 Correct 13 ms 320 KB Output is correct
44 Correct 40 ms 316 KB Output is correct
45 Correct 253 ms 332 KB Output is correct
46 Correct 752 ms 452 KB Output is correct
47 Correct 665 ms 468 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 838 ms 448 KB Output is correct
50 Correct 807 ms 476 KB Output is correct
51 Correct 72 ms 304 KB Output is correct
52 Execution timed out 1076 ms 328 KB Time limit exceeded
53 Halted 0 ms 0 KB -