Submission #278834

# Submission time Handle Problem Language Result Execution time Memory
278834 2020-08-22T00:43:37 Z jainbot27 Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1000 ms 1564 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
const int N = 2001;
int dp[N], a[N], n, aa, b, dp1[N][N];
ll mx = 0, p[N];

bool works(int bit){
    /*
    if(aa == 1){
        ll most = mx + (1LL << bit);
        for(int i=0; i<=n; i++){
            dp[i] = 1e9;
        }
        dp[0] = 0;
        for(int i=1; i <= n; i++){
            for(int j = 0; j < i; j++){
                ll sum = p[i] - p[j]; 
                if((sum|mx) < most){
                    dp[i] = min(dp[i], dp[j] + 1);
                }
            }
        }
        return dp[n]>b;
    }
    else{
    */
        cerr << "BIT " << bit << "\n";
        ll most = mx + (1LL << bit);
        for(int i=0; i <= n; i++){
            for(int j=0; j <= n; j++){
                dp1[i][j] = 0;
            }
        }
        dp1[0][0] = 1;
        for(int i=1; i<=n; i++){
            for(int j=1; j <= i; j++){
                for(int k=0; k <= i; k++){
                    if(dp1[k][j-1] && ((p[i] - p[k])|mx)<most){
                        dp1[i][j]|=1;
                    }
                }
            }
        }
        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= n; j++){
                cerr << "(" << i << "," << j << ") " << dp1[i][j] << "\n";
            }
        }
        for(int i = aa; i <= b; i++){
            if(dp1[n][i]){
                return 0;
            }
        }
        return 1;
    //}
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> aa >> b;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        p[i] = p[i-1] + a[i];
    }
    for(int bit = 40; bit >= 0; bit--){
        if(works(bit)){
            mx += 1LL << bit;
        }
    }
    cout << mx << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 31 ms 384 KB Output is correct
2 Correct 51 ms 456 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 23 ms 384 KB Output is correct
5 Correct 75 ms 384 KB Output is correct
6 Correct 157 ms 504 KB Output is correct
7 Correct 215 ms 632 KB Output is correct
8 Correct 270 ms 632 KB Output is correct
9 Correct 274 ms 632 KB Output is correct
10 Correct 290 ms 632 KB Output is correct
11 Correct 275 ms 540 KB Output is correct
12 Correct 274 ms 632 KB Output is correct
13 Correct 271 ms 636 KB Output is correct
14 Correct 37 ms 384 KB Output is correct
15 Incorrect 33 ms 384 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 384 KB Output is correct
2 Correct 50 ms 444 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 24 ms 384 KB Output is correct
5 Correct 87 ms 384 KB Output is correct
6 Correct 161 ms 504 KB Output is correct
7 Correct 199 ms 504 KB Output is correct
8 Correct 292 ms 632 KB Output is correct
9 Correct 277 ms 632 KB Output is correct
10 Correct 276 ms 636 KB Output is correct
11 Correct 272 ms 760 KB Output is correct
12 Correct 273 ms 632 KB Output is correct
13 Correct 272 ms 760 KB Output is correct
14 Correct 31 ms 384 KB Output is correct
15 Incorrect 30 ms 384 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 384 KB Output is correct
2 Correct 51 ms 448 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 23 ms 504 KB Output is correct
5 Correct 75 ms 384 KB Output is correct
6 Correct 166 ms 556 KB Output is correct
7 Correct 200 ms 504 KB Output is correct
8 Correct 275 ms 712 KB Output is correct
9 Correct 272 ms 632 KB Output is correct
10 Correct 273 ms 636 KB Output is correct
11 Correct 272 ms 632 KB Output is correct
12 Correct 271 ms 556 KB Output is correct
13 Correct 271 ms 636 KB Output is correct
14 Correct 297 ms 636 KB Output is correct
15 Correct 437 ms 888 KB Output is correct
16 Correct 957 ms 1272 KB Output is correct
17 Execution timed out 1083 ms 1284 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 384 KB Output is correct
2 Correct 50 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 25 ms 384 KB Output is correct
5 Correct 75 ms 384 KB Output is correct
6 Correct 158 ms 636 KB Output is correct
7 Correct 206 ms 504 KB Output is correct
8 Correct 268 ms 544 KB Output is correct
9 Correct 273 ms 632 KB Output is correct
10 Correct 288 ms 636 KB Output is correct
11 Correct 273 ms 632 KB Output is correct
12 Correct 274 ms 636 KB Output is correct
13 Correct 278 ms 632 KB Output is correct
14 Correct 31 ms 384 KB Output is correct
15 Incorrect 31 ms 384 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 384 KB Output is correct
2 Correct 50 ms 456 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 23 ms 384 KB Output is correct
5 Correct 74 ms 480 KB Output is correct
6 Correct 158 ms 484 KB Output is correct
7 Correct 205 ms 504 KB Output is correct
8 Correct 282 ms 632 KB Output is correct
9 Correct 282 ms 632 KB Output is correct
10 Correct 281 ms 632 KB Output is correct
11 Correct 278 ms 632 KB Output is correct
12 Correct 274 ms 632 KB Output is correct
13 Correct 274 ms 632 KB Output is correct
14 Correct 28 ms 384 KB Output is correct
15 Correct 77 ms 512 KB Output is correct
16 Correct 124 ms 632 KB Output is correct
17 Correct 245 ms 632 KB Output is correct
18 Correct 271 ms 760 KB Output is correct
19 Correct 268 ms 760 KB Output is correct
20 Correct 271 ms 632 KB Output is correct
21 Correct 269 ms 632 KB Output is correct
22 Correct 272 ms 648 KB Output is correct
23 Correct 272 ms 632 KB Output is correct
24 Correct 296 ms 632 KB Output is correct
25 Correct 418 ms 820 KB Output is correct
26 Correct 939 ms 1144 KB Output is correct
27 Execution timed out 1082 ms 1564 KB Time limit exceeded
28 Halted 0 ms 0 KB -