Submission #757419

#TimeUsernameProblemLanguageResultExecution timeMemory
757419Trisanu_DasBali Sculptures (APIO15_sculpture)C++17
100 / 100
80 ms408 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int n, s, e; cin >> n >> s >> e; int a[n + 1]; for(int i = 1; i < n + 1; i++) cin >> a[i]; int ans = (1LL << 41) - 1; int l[n + 1], r[n + 1]; l[0] = r[0] = 0; for(int k = 40; k > -1; k--) { ans ^= 1LL << k; for(int i = 1; i <= n; i++) { l[i] = INT_MAX, r[i] = INT_MIN; int s = 0; for(int j = i-1; j > -1; j--) { s += a[j + 1]; if((s & ans) == s) { l[i] = min(l[i], l[j] + 1); r[i] = max(r[i], r[j] + 1); } } } if(!(s <= r[n] && l[n] <= e)) ans ^= 1LL << k; } cout << ans << '\n'; }
#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...