Submission #942927

#TimeUsernameProblemLanguageResultExecution timeMemory
942927HiepVu217Bali Sculptures (APIO15_sculpture)C++17
50 / 100
66 ms856 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e3 + 17; int f[N], a[N], n, u, v; long long ans, s[N]; bool check (long long a, long long b, long long c) { return (a | b) < (b | c); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> u >> v; for (int i = 1; i <= n; ++i) { cin >> a[i]; s[i] = s[i - 1] + a[i]; } for (int i = 40; i >= 0; --i) { long long x = 1LL << i; for (int j = 1; j <= n; ++j) { f[j] = n + 1; for (int k = 0; k < j; ++k) { if (check (s[j] - s[k], ans, x)) { f[j] = min (f[j], f[k] + 1); } } } if (f[n] > v) { ans += x; } } cout << ans; }
#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...