# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
896075 | 2023-12-31T16:43:56 Z | AgentPengin | Bali Sculptures (APIO15_sculpture) | C++14 | 280 ms | 2904 KB |
/** * author: AgentPengin ( Độc cô cầu bại ) * created: 23.12.2022 10:08:02 * too lazy to update time **/ #include<bits/stdc++.h> #define EL '\n' #define fi first #define se second #define NAME "TASK" #define ll long long #define lcm(a,b) (a/gcd(a,b))*b #define db(val) "["#val" = " << (val) << "] " #define bend(v) (v).begin(),(v).end() #define sz(v) (int)(v).size() #define ex exit(0) #define int ll using namespace std; const ll mod = 1e9 + 7; const int inf = 0x1FFFFFFF; const int MAXN = 1e5 + 5; int n,A,B,pre[2005]; namespace sub1 { ll ans = 0; bool dp[2009][2009]; bool check(int bit) { for (int i = 0;i <= 100;i++) { for (int j = 0;j <= 100;j++) dp[i][j] = false; } dp[0][0]=true; for (int i = 0;i < n;i++) { for (int j = 0;j <= i;j++) { for (int t = i + 1;t <=n;t++) { int val = pre[t]-pre[i]; if (val >> bit & 1 ^ 1 && (val | ans) <= ans + (1LL << bit) - 1) dp[t][j+1] |=dp[i][j]; } } } for(int j = A;j <= B;j++) { if (dp[n][j]) return true; } return false; } void solve() { for (int bit = 40;bit >= 0;bit--) { if (!check(bit)) ans |= (1LL << bit); } cout << ans; } } namespace sub2 { ll ans = 0; int f[2005]; bool check(int bit) { memset(f,0x3f,sizeof f); f[0] = 0; for (int i = 0;i < n;i++) { for (int t = i + 1; t <= n;t++) { int val = pre[t] - pre[i]; if (val >> bit & 1 ^ 1 && (val | ans) <= ans + (1LL << bit) - 1) f[t] = min(f[t],f[i] + 1); } } return f[n] <= B; } void solve() { for(int bit = 40;bit >= 0;bit--) { if (!check(bit)) ans |= (1LL << bit); } cout << ans; } } signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); if (ifstream(NAME".inp")) { freopen(NAME".inp","r",stdin); freopen(NAME".out","w",stdout); } cin >> n >> A >> B; for (int i = 1;i <= n;i++) { int x; cin >> x; pre[i]=pre[i-1] + x; } if (n <=100)sub1::solve(); else sub2::solve(); cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; return 0; } // agent pengin wants to take apio (with anya-san)
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2512 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2668 KB | Output is correct |
4 | Correct | 1 ms | 2652 KB | Output is correct |
5 | Correct | 1 ms | 2648 KB | Output is correct |
6 | Correct | 1 ms | 2652 KB | Output is correct |
7 | Correct | 1 ms | 2648 KB | Output is correct |
8 | Correct | 1 ms | 2512 KB | Output is correct |
9 | Correct | 1 ms | 2652 KB | Output is correct |
10 | Correct | 1 ms | 2652 KB | Output is correct |
11 | Correct | 1 ms | 2652 KB | Output is correct |
12 | Correct | 1 ms | 2512 KB | Output is correct |
13 | Correct | 2 ms | 2652 KB | Output is correct |
14 | Correct | 1 ms | 2652 KB | Output is correct |
15 | Correct | 1 ms | 2680 KB | Output is correct |
16 | Correct | 1 ms | 2648 KB | Output is correct |
17 | Correct | 1 ms | 2652 KB | Output is correct |
18 | Correct | 1 ms | 2652 KB | Output is correct |
19 | Correct | 1 ms | 2652 KB | Output is correct |
20 | Correct | 1 ms | 2652 KB | Output is correct |
21 | Correct | 1 ms | 2652 KB | Output is correct |
22 | Correct | 1 ms | 2652 KB | Output is correct |
23 | Correct | 1 ms | 2648 KB | Output is correct |
24 | Correct | 1 ms | 2652 KB | Output is correct |
25 | Correct | 1 ms | 2472 KB | Output is correct |
26 | Correct | 1 ms | 2652 KB | Output is correct |
27 | Correct | 1 ms | 2652 KB | Output is correct |
28 | Correct | 1 ms | 2516 KB | Output is correct |
29 | Correct | 1 ms | 2652 KB | Output is correct |
30 | Correct | 2 ms | 2648 KB | Output is correct |
31 | Correct | 1 ms | 2648 KB | Output is correct |
32 | Correct | 1 ms | 2652 KB | Output is correct |
33 | Correct | 1 ms | 2652 KB | Output is correct |
34 | Correct | 1 ms | 2652 KB | Output is correct |
35 | Correct | 1 ms | 2652 KB | Output is correct |
36 | Correct | 1 ms | 2652 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2652 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2652 KB | Output is correct |
4 | Correct | 1 ms | 2652 KB | Output is correct |
5 | Correct | 1 ms | 2508 KB | Output is correct |
6 | Correct | 1 ms | 2652 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 1 ms | 2680 KB | Output is correct |
9 | Correct | 1 ms | 2648 KB | Output is correct |
10 | Correct | 1 ms | 2652 KB | Output is correct |
11 | Correct | 1 ms | 2516 KB | Output is correct |
12 | Correct | 1 ms | 2652 KB | Output is correct |
13 | Correct | 1 ms | 2652 KB | Output is correct |
14 | Correct | 1 ms | 2648 KB | Output is correct |
15 | Correct | 1 ms | 2648 KB | Output is correct |
16 | Correct | 1 ms | 2652 KB | Output is correct |
17 | Correct | 1 ms | 2652 KB | Output is correct |
18 | Correct | 1 ms | 2652 KB | Output is correct |
19 | Correct | 1 ms | 2652 KB | Output is correct |
20 | Correct | 1 ms | 2652 KB | Output is correct |
21 | Correct | 1 ms | 2652 KB | Output is correct |
22 | Correct | 1 ms | 2652 KB | Output is correct |
23 | Correct | 1 ms | 2652 KB | Output is correct |
24 | Correct | 1 ms | 2652 KB | Output is correct |
25 | Correct | 1 ms | 2652 KB | Output is correct |
26 | Correct | 1 ms | 2512 KB | Output is correct |
27 | Correct | 1 ms | 2648 KB | Output is correct |
28 | Correct | 1 ms | 2648 KB | Output is correct |
29 | Correct | 1 ms | 2512 KB | Output is correct |
30 | Correct | 1 ms | 2904 KB | Output is correct |
31 | Correct | 1 ms | 2692 KB | Output is correct |
32 | Correct | 2 ms | 2688 KB | Output is correct |
33 | Correct | 2 ms | 2652 KB | Output is correct |
34 | Correct | 2 ms | 2652 KB | Output is correct |
35 | Correct | 2 ms | 2652 KB | Output is correct |
36 | Correct | 2 ms | 2652 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2648 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2652 KB | Output is correct |
4 | Correct | 1 ms | 2652 KB | Output is correct |
5 | Correct | 1 ms | 2652 KB | Output is correct |
6 | Correct | 1 ms | 2652 KB | Output is correct |
7 | Correct | 1 ms | 2648 KB | Output is correct |
8 | Correct | 1 ms | 2652 KB | Output is correct |
9 | Correct | 2 ms | 2648 KB | Output is correct |
10 | Correct | 2 ms | 2808 KB | Output is correct |
11 | Correct | 1 ms | 2648 KB | Output is correct |
12 | Correct | 1 ms | 2652 KB | Output is correct |
13 | Correct | 1 ms | 2652 KB | Output is correct |
14 | Correct | 1 ms | 2652 KB | Output is correct |
15 | Correct | 1 ms | 2652 KB | Output is correct |
16 | Correct | 1 ms | 2652 KB | Output is correct |
17 | Correct | 1 ms | 2648 KB | Output is correct |
18 | Correct | 2 ms | 2652 KB | Output is correct |
19 | Correct | 2 ms | 2652 KB | Output is correct |
20 | Correct | 2 ms | 2652 KB | Output is correct |
21 | Correct | 2 ms | 2652 KB | Output is correct |
22 | Correct | 2 ms | 2652 KB | Output is correct |
23 | Correct | 3 ms | 2648 KB | Output is correct |
24 | Correct | 2 ms | 2652 KB | Output is correct |
25 | Correct | 3 ms | 2512 KB | Output is correct |
26 | Correct | 4 ms | 2652 KB | Output is correct |
27 | Correct | 7 ms | 2652 KB | Output is correct |
28 | Correct | 8 ms | 2684 KB | Output is correct |
29 | Correct | 8 ms | 2904 KB | Output is correct |
30 | Correct | 8 ms | 2652 KB | Output is correct |
31 | Correct | 8 ms | 2684 KB | Output is correct |
32 | Correct | 11 ms | 2680 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2652 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2648 KB | Output is correct |
4 | Correct | 1 ms | 2652 KB | Output is correct |
5 | Correct | 1 ms | 2652 KB | Output is correct |
6 | Correct | 1 ms | 2652 KB | Output is correct |
7 | Correct | 2 ms | 2652 KB | Output is correct |
8 | Correct | 2 ms | 2652 KB | Output is correct |
9 | Correct | 1 ms | 2508 KB | Output is correct |
10 | Correct | 1 ms | 2652 KB | Output is correct |
11 | Correct | 1 ms | 2652 KB | Output is correct |
12 | Correct | 1 ms | 2652 KB | Output is correct |
13 | Correct | 2 ms | 2652 KB | Output is correct |
14 | Correct | 1 ms | 2652 KB | Output is correct |
15 | Correct | 1 ms | 2652 KB | Output is correct |
16 | Correct | 1 ms | 2652 KB | Output is correct |
17 | Correct | 1 ms | 2652 KB | Output is correct |
18 | Correct | 1 ms | 2652 KB | Output is correct |
19 | Correct | 2 ms | 2652 KB | Output is correct |
20 | Correct | 1 ms | 2652 KB | Output is correct |
21 | Correct | 1 ms | 2904 KB | Output is correct |
22 | Correct | 1 ms | 2648 KB | Output is correct |
23 | Correct | 1 ms | 2652 KB | Output is correct |
24 | Correct | 1 ms | 2648 KB | Output is correct |
25 | Correct | 1 ms | 2648 KB | Output is correct |
26 | Correct | 1 ms | 2652 KB | Output is correct |
27 | Correct | 1 ms | 2652 KB | Output is correct |
28 | Correct | 1 ms | 2648 KB | Output is correct |
29 | Correct | 1 ms | 2652 KB | Output is correct |
30 | Correct | 1 ms | 2648 KB | Output is correct |
31 | Correct | 1 ms | 2652 KB | Output is correct |
32 | Correct | 1 ms | 2652 KB | Output is correct |
33 | Correct | 1 ms | 2652 KB | Output is correct |
34 | Correct | 1 ms | 2680 KB | Output is correct |
35 | Correct | 1 ms | 2652 KB | Output is correct |
36 | Correct | 1 ms | 2652 KB | Output is correct |
37 | Correct | 1 ms | 2652 KB | Output is correct |
38 | Correct | 1 ms | 2652 KB | Output is correct |
39 | Correct | 1 ms | 2652 KB | Output is correct |
40 | Correct | 1 ms | 2576 KB | Output is correct |
41 | Correct | 2 ms | 2652 KB | Output is correct |
42 | Correct | 2 ms | 2648 KB | Output is correct |
43 | Correct | 2 ms | 2652 KB | Output is correct |
44 | Correct | 2 ms | 2648 KB | Output is correct |
45 | Correct | 2 ms | 2652 KB | Output is correct |
46 | Correct | 2 ms | 2652 KB | Output is correct |
47 | Correct | 2 ms | 2440 KB | Output is correct |
48 | Correct | 3 ms | 2652 KB | Output is correct |
49 | Correct | 4 ms | 2652 KB | Output is correct |
50 | Correct | 6 ms | 2684 KB | Output is correct |
51 | Correct | 8 ms | 2648 KB | Output is correct |
52 | Correct | 7 ms | 2652 KB | Output is correct |
53 | Correct | 7 ms | 2652 KB | Output is correct |
54 | Correct | 8 ms | 2684 KB | Output is correct |
55 | Correct | 9 ms | 2648 KB | Output is correct |
56 | Correct | 2 ms | 2648 KB | Output is correct |
57 | Correct | 5 ms | 2648 KB | Output is correct |
58 | Correct | 8 ms | 2652 KB | Output is correct |
59 | Correct | 11 ms | 2512 KB | Output is correct |
60 | Correct | 7 ms | 2648 KB | Output is correct |
61 | Correct | 8 ms | 2652 KB | Output is correct |
62 | Correct | 9 ms | 2512 KB | Output is correct |
63 | Correct | 9 ms | 2652 KB | Output is correct |
64 | Correct | 6 ms | 2652 KB | Output is correct |
65 | Correct | 2 ms | 2652 KB | Output is correct |
66 | Correct | 4 ms | 2652 KB | Output is correct |
67 | Correct | 5 ms | 2652 KB | Output is correct |
68 | Correct | 8 ms | 2652 KB | Output is correct |
69 | Correct | 10 ms | 2476 KB | Output is correct |
70 | Correct | 8 ms | 2512 KB | Output is correct |
71 | Correct | 8 ms | 2652 KB | Output is correct |
72 | Correct | 9 ms | 2684 KB | Output is correct |
73 | Correct | 10 ms | 2652 KB | Output is correct |
74 | Correct | 9 ms | 2688 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2652 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2652 KB | Output is correct |
4 | Correct | 1 ms | 2652 KB | Output is correct |
5 | Correct | 1 ms | 2652 KB | Output is correct |
6 | Correct | 1 ms | 2652 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 1 ms | 2652 KB | Output is correct |
9 | Correct | 1 ms | 2652 KB | Output is correct |
10 | Correct | 1 ms | 2652 KB | Output is correct |
11 | Correct | 1 ms | 2652 KB | Output is correct |
12 | Correct | 1 ms | 2652 KB | Output is correct |
13 | Correct | 1 ms | 2596 KB | Output is correct |
14 | Correct | 1 ms | 2652 KB | Output is correct |
15 | Correct | 1 ms | 2652 KB | Output is correct |
16 | Correct | 1 ms | 2652 KB | Output is correct |
17 | Correct | 1 ms | 2652 KB | Output is correct |
18 | Correct | 1 ms | 2652 KB | Output is correct |
19 | Correct | 1 ms | 2652 KB | Output is correct |
20 | Correct | 1 ms | 2652 KB | Output is correct |
21 | Correct | 1 ms | 2512 KB | Output is correct |
22 | Correct | 1 ms | 2652 KB | Output is correct |
23 | Correct | 1 ms | 2652 KB | Output is correct |
24 | Correct | 1 ms | 2652 KB | Output is correct |
25 | Correct | 1 ms | 2652 KB | Output is correct |
26 | Correct | 1 ms | 2652 KB | Output is correct |
27 | Correct | 1 ms | 2652 KB | Output is correct |
28 | Correct | 2 ms | 2652 KB | Output is correct |
29 | Correct | 1 ms | 2648 KB | Output is correct |
30 | Correct | 2 ms | 2652 KB | Output is correct |
31 | Correct | 2 ms | 2516 KB | Output is correct |
32 | Correct | 2 ms | 2652 KB | Output is correct |
33 | Correct | 2 ms | 2652 KB | Output is correct |
34 | Correct | 2 ms | 2652 KB | Output is correct |
35 | Correct | 3 ms | 2652 KB | Output is correct |
36 | Correct | 4 ms | 2684 KB | Output is correct |
37 | Correct | 7 ms | 2652 KB | Output is correct |
38 | Correct | 8 ms | 2652 KB | Output is correct |
39 | Correct | 8 ms | 2652 KB | Output is correct |
40 | Correct | 7 ms | 2508 KB | Output is correct |
41 | Correct | 8 ms | 2512 KB | Output is correct |
42 | Correct | 8 ms | 2652 KB | Output is correct |
43 | Correct | 2 ms | 2652 KB | Output is correct |
44 | Correct | 5 ms | 2652 KB | Output is correct |
45 | Correct | 8 ms | 2652 KB | Output is correct |
46 | Correct | 10 ms | 2648 KB | Output is correct |
47 | Correct | 8 ms | 2652 KB | Output is correct |
48 | Correct | 8 ms | 2652 KB | Output is correct |
49 | Correct | 9 ms | 2652 KB | Output is correct |
50 | Correct | 9 ms | 2652 KB | Output is correct |
51 | Correct | 1 ms | 460 KB | Output is correct |
52 | Correct | 21 ms | 344 KB | Output is correct |
53 | Correct | 36 ms | 476 KB | Output is correct |
54 | Correct | 68 ms | 344 KB | Output is correct |
55 | Correct | 65 ms | 348 KB | Output is correct |
56 | Correct | 275 ms | 492 KB | Output is correct |
57 | Correct | 280 ms | 492 KB | Output is correct |
58 | Correct | 145 ms | 492 KB | Output is correct |
59 | Correct | 77 ms | 348 KB | Output is correct |
60 | Correct | 79 ms | 496 KB | Output is correct |
61 | Correct | 1 ms | 348 KB | Output is correct |
62 | Correct | 31 ms | 348 KB | Output is correct |
63 | Correct | 60 ms | 480 KB | Output is correct |
64 | Correct | 56 ms | 344 KB | Output is correct |
65 | Correct | 99 ms | 488 KB | Output is correct |
66 | Correct | 144 ms | 492 KB | Output is correct |
67 | Correct | 188 ms | 592 KB | Output is correct |
68 | Correct | 186 ms | 488 KB | Output is correct |
69 | Correct | 182 ms | 492 KB | Output is correct |