Submission #838906

# Submission time Handle Problem Language Result Execution time Memory
838906 2023-08-28T08:48:59 Z drkarlicio2107 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1 ms 596 KB
#include <bits/stdc++.h>
using namespace std;
int pref [2010];
int dp [35][2010];
int l [2010];
int main(){
    for (int i=0; i<35; i++){
        for (int j=0; j<2010; j++) dp [i][j]=1e9;
    }
    int n, gra, grb; cin >> n >> gra >> grb;
    for (int i=0; i<n; i++) cin >> l [i];
    pref [0]=l [0];
    for (int i=1; i<n; i++) pref [i]=pref [i-1]+l [i];
    int ans=0;
    for (int b=30; b>=0; b--){
        if ((((ans >> b) | ((pref [0])>>b)) == (ans >> b)) && (((pref [0]) & (1<<b)) == 0)){
            dp [b][0]=1;
        }
        for (int i=1; i<n; i++){
            for (int j=i-1; j>=0; j--){
                if ((((ans >> b) | ((pref [i]-pref [j])>>b)) == (ans >> b)) && (((pref [i]-pref [j]) & (1<<b)) == 0)) dp [b][i]=min (dp [b][i], dp [b][j]+1);
            }
        }
        //cout << dp [b][n-1] << " " << b << endl;
        if (dp [b][n-1]>grb) ans|=(1<<b);
    }
    cout << ans << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Incorrect 1 ms 596 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Incorrect 1 ms 480 KB Output isn't correct
3 Halted 0 ms 0 KB -