Submission #959560

# Submission time Handle Problem Language Result Execution time Memory
959560 2024-04-08T12:40:25 Z HossamHero7 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
bool dp[105][105];
int dp2[105];
void solve(){
    int n,l,r;
    cin>>n>>l>>r;
    vector<ll> v(n);
    for(auto &i:v) cin>>i;
    vector<ll> prefix = v;
    for(int i=1;i<n;i++) prefix[i] += prefix[i-1];
    auto getSum = [&](int i,int j){
        return prefix[j] - (i ? prefix[i-1] : 0);
    };
    if(n <= 100){
        ll cur = 0;
        for(int i=0;i<=n+1;i++) dp[n][i] = 1;
        for(int bt=41;bt>=0;bt--){
            for(int i=n-1;i>=0;i--){
                for(int j=0;j<=n;j++){
                    dp[i][j] = 0;
                    for(int k=i;k<n;k++){
                        if(((getSum(i,k) | cur) >> bt) == (cur>>bt)){
                            dp[i][j] |= dp[k+1][j+1];
                        }
                    }
                }
            }
            for(int i=l;i<=r;i++){
                if(dp[0][i]) goto gt;
            }
            cur |= (1LL<<(ll)bt);
            gt:continue;
        }
        cout<<cur<<endl;
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Incorrect 1 ms 500 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 1 ms 344 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 452 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -