Submission #587370

#TimeUsernameProblemLanguageResultExecution timeMemory
587370VanillaBali Sculptures (APIO15_sculpture)C++17
100 / 100
121 ms348 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int64; const int maxn = 2e3 + 2; int64 pref [maxn]; int64 arr[maxn]; int n,a,b; bool check (int64 rs) { int mn[maxn] = {}, mx[maxn] = {}; for (int i = 1; i <= n; i++){ mn[i] = 1e9, mx[i] = -1e9; for (int j = 0; j < i; j++){ if (((pref[i] - pref[j]) & rs) == (pref[i] - pref[j])) { mn[i] = min(mn[i], mn[j] + 1); mx[i] = max(mx[i], mx[j] + 1); } } } return mn[n] <= b && mx[n] >= a; } int main() { cin >> n >> a >> b; for (int i = 1; i <= n; i++){ cin >> arr[i]; pref[i] = pref[i-1] + arr[i]; } int64 rs = (1ll << 41) - 1; for (int64 i = 40; i >= 0; i--){ if (check(rs ^ (1ll << i))) rs^=(1ll << i); } cout << rs << "\n"; return 0; }
#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...