Submission #108940

#TimeUsernameProblemLanguageResultExecution timeMemory
108940mirbek01Bali Sculptures (APIO15_sculpture)C++11
71 / 100
1071 ms16248 KiB
# include <bits/stdc++.h> using namespace std; const int N = 2e3 + 2; int n, a[N], dp[N][N], l, r; long long pref[N], ans; bool ok(long long x, int ind){ for(int i = ind; i <= 40; i ++){ if((x >> i) % 2 && (ans >> i) % 2 == 0) return 0; } return 1; } bool check(int ind){ memset(dp, 0, sizeof(dp)); dp[0][0] = 1; for(int i = 1; i <= r; i ++){ for(int j = 1; j <= n; j ++){ for(int k = 0; k < j; k ++){ if(ok(pref[j] - pref[k], ind)){ dp[i][j] |= dp[i - 1][k]; } } } } int ret = 0; for(int i = l; i <= r; i ++){ ret |= dp[i][n]; } return ret; } int main(){ cin >> n >> l >> r; for(int i = 1; i <= n; i ++){ cin >> a[i]; pref[i] = pref[i - 1] + a[i]; } for(int i = 40; i >= 0; i --){ if(!check(i)) ans += (1LL << i); } cout << ans << endl; }
#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...