답안 #527587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
527587 2022-02-17T17:34:33 Z SlavicG Bali Sculptures (APIO15_sculpture) C++17
37 / 100
93 ms 16088 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long
 
#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()
 
#define            pb                push_back
#define          sz(a)               (int)a.size()

const int N = 2005;
ll p[N];
int sum(int l, int r) {
    return p[r] - (l ? p[l - 1] : 0);
}

//dp[index][OR][number of subarrays] = 1 if possible to obtain such partition

int dp[N][N];
ll excluded;

bool check(ll k, int n, vector<ll>& a, int A, int B) {
    for(int i = 0;i < N; ++i) for(int j = 0;j < N; ++j) dp[i][j] = 0;
    dp[0][0] = 1;
    for(int i = 1; i <= n; ++i) {
        for(int j = 0;j < i; ++j) {
            ll s = sum(j, i - 1);
            if((s & excluded) || (s & (1LL << k))) continue;
            for(int x = 0;x < n; ++x) {
                dp[i][x + 1] |= dp[j][x];
            }
        }
    }
    for(int j = A; j <= B; ++j) {
        if(dp[n][j]) return true;
    }
    return false;
}

void solve() { 
    ll n, A, B;
    cin >> n >> A >> B;
    vector<ll> a(n);
    for(int i = 0;i < n; ++i) {
        cin >> a[i];
        p[i] = (i ? p[i - 1] : 0) + a[i];
    }

    ll ans = 0;
    for(ll pw = 40; pw >= 0; --pw) {
        if(check(pw, n, a, A, B)) {
            excluded += (1LL << pw);
        } else {
            ans += (1LL << pw);
        }
    }
    cout << ans << "\n";
} 
 
int32_t main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 16032 KB Output is correct
2 Correct 75 ms 16028 KB Output is correct
3 Correct 88 ms 16024 KB Output is correct
4 Correct 78 ms 16028 KB Output is correct
5 Correct 68 ms 16028 KB Output is correct
6 Correct 74 ms 16028 KB Output is correct
7 Correct 72 ms 15948 KB Output is correct
8 Correct 81 ms 16068 KB Output is correct
9 Correct 75 ms 16028 KB Output is correct
10 Correct 77 ms 16028 KB Output is correct
11 Correct 72 ms 16028 KB Output is correct
12 Correct 72 ms 15948 KB Output is correct
13 Correct 77 ms 16024 KB Output is correct
14 Correct 92 ms 16024 KB Output is correct
15 Correct 82 ms 15948 KB Output is correct
16 Correct 71 ms 15948 KB Output is correct
17 Correct 74 ms 15948 KB Output is correct
18 Correct 73 ms 16028 KB Output is correct
19 Correct 86 ms 16060 KB Output is correct
20 Correct 74 ms 16028 KB Output is correct
21 Correct 77 ms 15948 KB Output is correct
22 Correct 78 ms 15948 KB Output is correct
23 Correct 73 ms 16024 KB Output is correct
24 Correct 76 ms 16024 KB Output is correct
25 Correct 80 ms 16060 KB Output is correct
26 Correct 72 ms 15948 KB Output is correct
27 Correct 73 ms 16024 KB Output is correct
28 Incorrect 73 ms 16028 KB Output isn't correct
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 15948 KB Output is correct
2 Correct 78 ms 15948 KB Output is correct
3 Correct 75 ms 16044 KB Output is correct
4 Correct 71 ms 15948 KB Output is correct
5 Correct 71 ms 16028 KB Output is correct
6 Correct 85 ms 15948 KB Output is correct
7 Correct 75 ms 15948 KB Output is correct
8 Correct 74 ms 15992 KB Output is correct
9 Correct 72 ms 15948 KB Output is correct
10 Correct 74 ms 15948 KB Output is correct
11 Correct 72 ms 16028 KB Output is correct
12 Correct 83 ms 16032 KB Output is correct
13 Correct 82 ms 15948 KB Output is correct
14 Correct 70 ms 15948 KB Output is correct
15 Correct 71 ms 16024 KB Output is correct
16 Correct 74 ms 16040 KB Output is correct
17 Correct 73 ms 15948 KB Output is correct
18 Correct 71 ms 15948 KB Output is correct
19 Correct 72 ms 15948 KB Output is correct
20 Correct 71 ms 15980 KB Output is correct
21 Correct 70 ms 16024 KB Output is correct
22 Correct 74 ms 16024 KB Output is correct
23 Correct 72 ms 16032 KB Output is correct
24 Correct 74 ms 15936 KB Output is correct
25 Correct 78 ms 15948 KB Output is correct
26 Correct 75 ms 15948 KB Output is correct
27 Correct 83 ms 16028 KB Output is correct
28 Correct 79 ms 16028 KB Output is correct
29 Correct 80 ms 15948 KB Output is correct
30 Correct 79 ms 15948 KB Output is correct
31 Correct 78 ms 15948 KB Output is correct
32 Correct 74 ms 16040 KB Output is correct
33 Correct 89 ms 15948 KB Output is correct
34 Correct 78 ms 16024 KB Output is correct
35 Correct 77 ms 16024 KB Output is correct
36 Correct 82 ms 15948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 15948 KB Output is correct
2 Correct 73 ms 16028 KB Output is correct
3 Correct 83 ms 16028 KB Output is correct
4 Correct 84 ms 15948 KB Output is correct
5 Correct 79 ms 16020 KB Output is correct
6 Correct 73 ms 16028 KB Output is correct
7 Correct 71 ms 16032 KB Output is correct
8 Correct 72 ms 16040 KB Output is correct
9 Correct 77 ms 16028 KB Output is correct
10 Correct 74 ms 15948 KB Output is correct
11 Correct 85 ms 16032 KB Output is correct
12 Correct 75 ms 16024 KB Output is correct
13 Correct 72 ms 16036 KB Output is correct
14 Correct 74 ms 16036 KB Output is correct
15 Correct 74 ms 15948 KB Output is correct
16 Correct 86 ms 15952 KB Output is correct
17 Correct 73 ms 16032 KB Output is correct
18 Correct 74 ms 16024 KB Output is correct
19 Correct 77 ms 15960 KB Output is correct
20 Correct 81 ms 16088 KB Output is correct
21 Correct 77 ms 15960 KB Output is correct
22 Correct 75 ms 16036 KB Output is correct
23 Correct 85 ms 16040 KB Output is correct
24 Correct 77 ms 16040 KB Output is correct
25 Correct 91 ms 16040 KB Output is correct
26 Correct 93 ms 16040 KB Output is correct
27 Correct 79 ms 16040 KB Output is correct
28 Correct 83 ms 15948 KB Output is correct
29 Correct 86 ms 16032 KB Output is correct
30 Correct 89 ms 15948 KB Output is correct
31 Correct 92 ms 15948 KB Output is correct
32 Correct 88 ms 16024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 15948 KB Output is correct
2 Correct 74 ms 16028 KB Output is correct
3 Correct 77 ms 15948 KB Output is correct
4 Correct 80 ms 16024 KB Output is correct
5 Correct 78 ms 16040 KB Output is correct
6 Correct 70 ms 15948 KB Output is correct
7 Correct 73 ms 16024 KB Output is correct
8 Correct 73 ms 15948 KB Output is correct
9 Correct 74 ms 16032 KB Output is correct
10 Correct 74 ms 16028 KB Output is correct
11 Correct 76 ms 16028 KB Output is correct
12 Correct 75 ms 16024 KB Output is correct
13 Correct 74 ms 15948 KB Output is correct
14 Correct 71 ms 15948 KB Output is correct
15 Correct 73 ms 15948 KB Output is correct
16 Correct 75 ms 16028 KB Output is correct
17 Correct 74 ms 16028 KB Output is correct
18 Correct 77 ms 15948 KB Output is correct
19 Correct 76 ms 15948 KB Output is correct
20 Correct 74 ms 16028 KB Output is correct
21 Correct 74 ms 16032 KB Output is correct
22 Correct 75 ms 15948 KB Output is correct
23 Correct 81 ms 16040 KB Output is correct
24 Correct 75 ms 16028 KB Output is correct
25 Correct 74 ms 16028 KB Output is correct
26 Correct 80 ms 16028 KB Output is correct
27 Correct 78 ms 16028 KB Output is correct
28 Incorrect 75 ms 16040 KB Output isn't correct
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 16028 KB Output is correct
2 Correct 83 ms 16032 KB Output is correct
3 Correct 83 ms 16028 KB Output is correct
4 Correct 81 ms 16004 KB Output is correct
5 Correct 70 ms 15948 KB Output is correct
6 Correct 71 ms 15948 KB Output is correct
7 Correct 75 ms 15948 KB Output is correct
8 Correct 73 ms 16076 KB Output is correct
9 Correct 79 ms 16028 KB Output is correct
10 Correct 82 ms 16032 KB Output is correct
11 Correct 73 ms 15948 KB Output is correct
12 Correct 71 ms 15948 KB Output is correct
13 Correct 77 ms 15948 KB Output is correct
14 Correct 83 ms 15948 KB Output is correct
15 Incorrect 73 ms 15948 KB Output isn't correct
16 Halted 0 ms 0 KB -