Submission #882793

#TimeUsernameProblemLanguageResultExecution timeMemory
882793NotLinuxBali Sculptures (APIO15_sculpture)C++17
71 / 100
37 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 105; int n,a,b,y[N],pre[N]; bool check(int past){ bool dp[n+1][n+1]; memset(dp , 0 , sizeof(dp)); dp[0][0] = 1; for(int i = 1;i<=n;i++){ for(int j = 1;j<=n;j++){ for(int k = i-1;k>=0;k--){ int range_sum = pre[i] - pre[k]; dp[i][j] |= dp[k][j-1] & ((range_sum & past) == 0); } } } for(int i = a;i<=b;i++){ if(dp[n][i]){ return 1; } } return 0; } void solve(){ cin >> n >> a >> b; for(int i = 0;i<n;i++){ cin >> y[i]; } for(int i = 0;i<n;i++){ pre[i+1] = pre[i] + y[i]; } int dont = 0 , ans = 0; for(int i = 40;i>=0;i--){ if(check(dont + (1ll<<i))){//olmadan da oluyor dont += 1ll << i; } else{//olmadan olmuyor ans += 1ll << i; } } cout << ans << endl; } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); int testcase = 1;//cin >> testcase; while(testcase--)solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...