Submission #838952

# Submission time Handle Problem Language Result Execution time Memory
838952 2023-08-28T10:25:51 Z drkarlicio2107 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1 ms 1620 KB
#include <bits/stdc++.h>
using namespace std;
long long int dp [50][210][210];
long long int dp2 [50][2010];
long long int l [2010];
long long int pref [2010];
int main (){
    int n, gra, grb; cin >> n >> gra >> grb;
    if (gra==1){
        for (int i=0; i<50; i++){
            for (int j=0; j<2010; j++) dp2 [i][j]=1e18;
        }
        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];
        long long int ans=0;
        for (long long int b=49; b>=0; b--){
            for (int i=0; i<n; i++){
                if ((((ans >> b) | ((pref [i])>>b)) == (ans >> b))) dp2 [b][i]=1;
                for (int j=i-1; j>=0; j--){
                    if ((((ans >> b) | ((pref [i]-pref [j])>>b)) == (ans >> b))) dp2 [b][i]=min (dp2 [b][i], dp2 [b][j]+1);
                }
            }
            if (dp2 [b][n-1]>grb) ans|=((long long)1<<b);
        }
        cout << ans << endl;
    }
    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];
    long long int ans=0;
    for (long long int b=49; b>=0; b--){
        for (int i=0; i<n; i++){
            for (int j=0; j<n+1; j++){
                if ((((ans >> b) | ((pref [i])>>b)) == (ans >> b))) dp [b][i][1]=1;
                for (int k=i-1; k>=0; k--){
                    if ((((ans >> b) | ((pref [i]-pref [k])>>b)) == (ans >> b))) dp [b][i][j]=max (dp [b][i][j], dp [b][k][j-1]);
                }
            }
        }
        int da=0;
        for (int i=gra; i<=grb; i++) if (dp [b][n-1][i]) da=1;
        if (!da) ans|=((long long)1<<b);
    }
    cout << ans << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -