답안 #974395

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
974395 2024-05-03T09:39:32 Z raul2008487 Bali Sculptures (APIO15_sculpture) C++17
71 / 100
1000 ms 6736 KB
#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define pb push_back
#define vl vector<ll>
#define fi first
#define se second
#define in insert
#define all(v) v.begin(), v.end()
#define bpc(x) __builtin_popcount(x)
#define endl "\n"

using namespace std;
const int sz = 2005; /// mind the sz
// using namespace __gnu_pbds;
// tree <ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> rbt;
ll n, A, B, pr[sz], a[sz], ca;
bool dp[sz][sz], used[sz][sz];
bool rec(ll idx, ll blocks, ll bt){
    if(idx == (n + 1)){
        return (A <= blocks && blocks <= B);
    }
    if(used[idx][blocks]){return dp[idx][blocks];}
    for(int j = idx + 1; j <= (n + 1); j++){
        ll t = (pr[j - 1] - pr[idx - 1]);
        if(((ca | t) >> bt << bt) == ca && rec(j, blocks + 1, bt)){
            return used[idx][blocks] = dp[idx][blocks] = 1;
        }
    }
    used[idx][blocks] = 1;
    return dp[idx][blocks] = 0;
}
void solve(){
    ll i, j;
    cin >> n >> A >> B;
    for(i = 1; i <= n; i++){
        cin >> a[i];
        pr[i] = pr[i - 1] + a[i];
    }
    for(i = 60; i >= 0; i--){
        // cout << i << ' ' << rec(1, 0, i) << endl;
        ca |= (!rec(1, 0, i)) * (1ll << i);
        memset(used, false, sizeof(used));
    }
    cout << ca << endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}
/*
6 1 3
8 1 2 1 5 4
*/

Compilation message

sculpture.cpp: In function 'void solve()':
sculpture.cpp:37:11: warning: unused variable 'j' [-Wunused-variable]
   37 |     ll i, j;
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4700 KB Output is correct
2 Correct 5 ms 4700 KB Output is correct
3 Correct 5 ms 4696 KB Output is correct
4 Correct 5 ms 4700 KB Output is correct
5 Correct 5 ms 4696 KB Output is correct
6 Correct 5 ms 4696 KB Output is correct
7 Correct 5 ms 4700 KB Output is correct
8 Correct 5 ms 4700 KB Output is correct
9 Correct 5 ms 4700 KB Output is correct
10 Correct 5 ms 4700 KB Output is correct
11 Correct 5 ms 4700 KB Output is correct
12 Correct 5 ms 4700 KB Output is correct
13 Correct 5 ms 4700 KB Output is correct
14 Correct 5 ms 4700 KB Output is correct
15 Correct 5 ms 4700 KB Output is correct
16 Correct 5 ms 4952 KB Output is correct
17 Correct 5 ms 4560 KB Output is correct
18 Correct 5 ms 4700 KB Output is correct
19 Correct 5 ms 4700 KB Output is correct
20 Correct 5 ms 4700 KB Output is correct
21 Correct 5 ms 4700 KB Output is correct
22 Correct 5 ms 4700 KB Output is correct
23 Correct 5 ms 4700 KB Output is correct
24 Correct 5 ms 4700 KB Output is correct
25 Correct 5 ms 4700 KB Output is correct
26 Correct 5 ms 4756 KB Output is correct
27 Correct 5 ms 4696 KB Output is correct
28 Correct 5 ms 4700 KB Output is correct
29 Correct 5 ms 4556 KB Output is correct
30 Correct 7 ms 4756 KB Output is correct
31 Correct 5 ms 4756 KB Output is correct
32 Correct 5 ms 4696 KB Output is correct
33 Correct 7 ms 4696 KB Output is correct
34 Correct 5 ms 4700 KB Output is correct
35 Correct 5 ms 4700 KB Output is correct
36 Correct 5 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4700 KB Output is correct
2 Correct 6 ms 4700 KB Output is correct
3 Correct 5 ms 4700 KB Output is correct
4 Correct 5 ms 4700 KB Output is correct
5 Correct 5 ms 4556 KB Output is correct
6 Correct 5 ms 4700 KB Output is correct
7 Correct 5 ms 4752 KB Output is correct
8 Correct 6 ms 4700 KB Output is correct
9 Correct 5 ms 4700 KB Output is correct
10 Correct 7 ms 4700 KB Output is correct
11 Correct 5 ms 4700 KB Output is correct
12 Correct 5 ms 4700 KB Output is correct
13 Correct 5 ms 4700 KB Output is correct
14 Correct 5 ms 4700 KB Output is correct
15 Correct 5 ms 4696 KB Output is correct
16 Correct 5 ms 4700 KB Output is correct
17 Correct 5 ms 4700 KB Output is correct
18 Correct 6 ms 4696 KB Output is correct
19 Correct 6 ms 4700 KB Output is correct
20 Correct 6 ms 4696 KB Output is correct
21 Correct 6 ms 4564 KB Output is correct
22 Correct 5 ms 4700 KB Output is correct
23 Correct 5 ms 4700 KB Output is correct
24 Correct 6 ms 4756 KB Output is correct
25 Correct 5 ms 4700 KB Output is correct
26 Correct 5 ms 4752 KB Output is correct
27 Correct 6 ms 4696 KB Output is correct
28 Correct 5 ms 4560 KB Output is correct
29 Correct 8 ms 4756 KB Output is correct
30 Correct 9 ms 4756 KB Output is correct
31 Correct 7 ms 4756 KB Output is correct
32 Correct 7 ms 4700 KB Output is correct
33 Correct 12 ms 4756 KB Output is correct
34 Correct 7 ms 4700 KB Output is correct
35 Correct 7 ms 4752 KB Output is correct
36 Correct 10 ms 4752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4700 KB Output is correct
2 Correct 5 ms 4700 KB Output is correct
3 Correct 5 ms 4700 KB Output is correct
4 Correct 5 ms 4700 KB Output is correct
5 Correct 5 ms 4712 KB Output is correct
6 Correct 6 ms 4700 KB Output is correct
7 Correct 6 ms 4752 KB Output is correct
8 Correct 6 ms 4700 KB Output is correct
9 Correct 5 ms 4556 KB Output is correct
10 Correct 6 ms 4696 KB Output is correct
11 Correct 5 ms 4556 KB Output is correct
12 Correct 5 ms 4700 KB Output is correct
13 Correct 5 ms 4700 KB Output is correct
14 Correct 5 ms 4952 KB Output is correct
15 Correct 5 ms 4696 KB Output is correct
16 Correct 7 ms 4696 KB Output is correct
17 Correct 6 ms 4700 KB Output is correct
18 Correct 7 ms 4700 KB Output is correct
19 Correct 6 ms 4756 KB Output is correct
20 Correct 11 ms 4696 KB Output is correct
21 Correct 6 ms 4700 KB Output is correct
22 Correct 7 ms 4700 KB Output is correct
23 Correct 8 ms 4696 KB Output is correct
24 Correct 7 ms 4700 KB Output is correct
25 Correct 13 ms 4700 KB Output is correct
26 Correct 13 ms 4700 KB Output is correct
27 Correct 7 ms 4696 KB Output is correct
28 Correct 6 ms 4700 KB Output is correct
29 Correct 7 ms 4700 KB Output is correct
30 Correct 47 ms 4696 KB Output is correct
31 Correct 13 ms 4696 KB Output is correct
32 Correct 7 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4756 KB Output is correct
2 Correct 6 ms 4700 KB Output is correct
3 Correct 5 ms 4700 KB Output is correct
4 Correct 5 ms 4700 KB Output is correct
5 Correct 5 ms 4700 KB Output is correct
6 Correct 5 ms 4756 KB Output is correct
7 Correct 5 ms 4696 KB Output is correct
8 Correct 5 ms 4700 KB Output is correct
9 Correct 5 ms 4756 KB Output is correct
10 Correct 5 ms 4700 KB Output is correct
11 Correct 5 ms 4700 KB Output is correct
12 Correct 6 ms 4564 KB Output is correct
13 Correct 5 ms 4700 KB Output is correct
14 Correct 5 ms 4700 KB Output is correct
15 Correct 5 ms 4700 KB Output is correct
16 Correct 5 ms 4700 KB Output is correct
17 Correct 5 ms 4696 KB Output is correct
18 Correct 5 ms 4700 KB Output is correct
19 Correct 5 ms 4700 KB Output is correct
20 Correct 5 ms 4700 KB Output is correct
21 Correct 5 ms 4700 KB Output is correct
22 Correct 6 ms 4700 KB Output is correct
23 Correct 5 ms 4700 KB Output is correct
24 Correct 6 ms 4760 KB Output is correct
25 Correct 5 ms 4700 KB Output is correct
26 Correct 5 ms 4700 KB Output is correct
27 Correct 5 ms 4700 KB Output is correct
28 Correct 5 ms 4752 KB Output is correct
29 Correct 5 ms 4700 KB Output is correct
30 Correct 5 ms 4700 KB Output is correct
31 Correct 5 ms 4756 KB Output is correct
32 Correct 5 ms 4700 KB Output is correct
33 Correct 5 ms 4700 KB Output is correct
34 Correct 5 ms 4700 KB Output is correct
35 Correct 5 ms 4700 KB Output is correct
36 Correct 5 ms 4700 KB Output is correct
37 Correct 5 ms 4760 KB Output is correct
38 Correct 6 ms 4696 KB Output is correct
39 Correct 7 ms 4700 KB Output is correct
40 Correct 6 ms 4700 KB Output is correct
41 Correct 7 ms 4752 KB Output is correct
42 Correct 6 ms 4700 KB Output is correct
43 Correct 12 ms 4752 KB Output is correct
44 Correct 6 ms 4700 KB Output is correct
45 Correct 7 ms 4696 KB Output is correct
46 Correct 11 ms 4700 KB Output is correct
47 Correct 6 ms 4700 KB Output is correct
48 Correct 13 ms 4700 KB Output is correct
49 Correct 14 ms 4700 KB Output is correct
50 Correct 7 ms 4700 KB Output is correct
51 Correct 6 ms 4700 KB Output is correct
52 Correct 7 ms 4580 KB Output is correct
53 Correct 48 ms 4696 KB Output is correct
54 Correct 13 ms 4700 KB Output is correct
55 Correct 8 ms 4760 KB Output is correct
56 Correct 6 ms 4696 KB Output is correct
57 Correct 10 ms 4756 KB Output is correct
58 Correct 7 ms 4700 KB Output is correct
59 Correct 6 ms 4700 KB Output is correct
60 Correct 6 ms 4700 KB Output is correct
61 Correct 27 ms 4696 KB Output is correct
62 Correct 6 ms 4700 KB Output is correct
63 Correct 6 ms 4756 KB Output is correct
64 Correct 5 ms 4696 KB Output is correct
65 Correct 7 ms 4700 KB Output is correct
66 Correct 10 ms 4752 KB Output is correct
67 Correct 10 ms 4700 KB Output is correct
68 Correct 7 ms 4700 KB Output is correct
69 Correct 6 ms 4700 KB Output is correct
70 Correct 6 ms 4700 KB Output is correct
71 Correct 27 ms 4724 KB Output is correct
72 Correct 7 ms 4756 KB Output is correct
73 Correct 7 ms 4696 KB Output is correct
74 Correct 7 ms 4560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4952 KB Output is correct
2 Correct 5 ms 4700 KB Output is correct
3 Correct 5 ms 4700 KB Output is correct
4 Correct 5 ms 4752 KB Output is correct
5 Correct 5 ms 4888 KB Output is correct
6 Correct 5 ms 4700 KB Output is correct
7 Correct 5 ms 4696 KB Output is correct
8 Correct 6 ms 4700 KB Output is correct
9 Correct 6 ms 4696 KB Output is correct
10 Correct 5 ms 4700 KB Output is correct
11 Correct 5 ms 4756 KB Output is correct
12 Correct 6 ms 4560 KB Output is correct
13 Correct 5 ms 4700 KB Output is correct
14 Correct 5 ms 4700 KB Output is correct
15 Correct 6 ms 4700 KB Output is correct
16 Correct 5 ms 4700 KB Output is correct
17 Correct 5 ms 4700 KB Output is correct
18 Correct 5 ms 4700 KB Output is correct
19 Correct 6 ms 4700 KB Output is correct
20 Correct 5 ms 4700 KB Output is correct
21 Correct 5 ms 4700 KB Output is correct
22 Correct 5 ms 4700 KB Output is correct
23 Correct 6 ms 4696 KB Output is correct
24 Correct 5 ms 4700 KB Output is correct
25 Correct 5 ms 4700 KB Output is correct
26 Correct 7 ms 4700 KB Output is correct
27 Correct 6 ms 4700 KB Output is correct
28 Correct 6 ms 4700 KB Output is correct
29 Correct 6 ms 4700 KB Output is correct
30 Correct 11 ms 4752 KB Output is correct
31 Correct 9 ms 4952 KB Output is correct
32 Correct 7 ms 4696 KB Output is correct
33 Correct 8 ms 4700 KB Output is correct
34 Correct 8 ms 4700 KB Output is correct
35 Correct 13 ms 4696 KB Output is correct
36 Correct 22 ms 4700 KB Output is correct
37 Correct 7 ms 4700 KB Output is correct
38 Correct 6 ms 4700 KB Output is correct
39 Correct 6 ms 4696 KB Output is correct
40 Correct 48 ms 4700 KB Output is correct
41 Correct 13 ms 4700 KB Output is correct
42 Correct 7 ms 4664 KB Output is correct
43 Correct 6 ms 4696 KB Output is correct
44 Correct 11 ms 4700 KB Output is correct
45 Correct 6 ms 4700 KB Output is correct
46 Correct 6 ms 4700 KB Output is correct
47 Correct 6 ms 4700 KB Output is correct
48 Correct 28 ms 4952 KB Output is correct
49 Correct 6 ms 4700 KB Output is correct
50 Correct 7 ms 4700 KB Output is correct
51 Correct 20 ms 4696 KB Output is correct
52 Execution timed out 1033 ms 6736 KB Time limit exceeded
53 Halted 0 ms 0 KB -