Submission #882788

#TimeUsernameProblemLanguageResultExecution timeMemory
882788NotLinuxBali Sculptures (APIO15_sculpture)C++17
37 / 100
18 ms456 KiB
#include <bits/stdc++.h> using namespace std; 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 = 30;i>=0;i--){ if(check(dont + (1<<i))){//olmadan da oluyor dont += 1 << i; } else{//olmadan olmuyor ans += 1 << 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...