Submission #1069086

# Submission time Handle Problem Language Result Execution time Memory
1069086 2024-08-21T15:45:14 Z Luvidi Bali Sculptures (APIO15_sculpture) C++17
0 / 100
2 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back

void solve() {
    freopen("in","r",stdin);
    freopen("out","w",stdout);
    int n,l,r;
    cin>>n>>l>>r;
    ll a[n+1];
    for(int i=1;i<=n;i++)cin>>a[i];
    ll ans=(1LL<<41)-1;
    for(int x=40;x>-1;x--){
        ans^=1LL<<x;
        int dp[n+1];
        dp[0]=0;
        for(int i=1;i<=n;i++){
            dp[i]=1e9;
            ll s=0;
            for(int j=i;j;j--){
                s+=a[j];
                if((s&ans)==s){
                    dp[i]=min(dp[i],dp[j-1]+1);
                }
            }
        }
        if(dp[n]>r)ans^=1LL<<x;
    }
    cout<<ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}

Compilation message

sculpture.cpp: In function 'void solve()':
sculpture.cpp:12:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen("in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~
sculpture.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen("out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -