Submission #1113247

#TimeUsernameProblemLanguageResultExecution timeMemory
1113247adaawfBali Sculptures (APIO15_sculpture)C++17
100 / 100
77 ms592 KiB
#include <iostream> using namespace std; long long int f[2005], c[2005], d[105][105]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, x, y; cin >> n >> x >> y; for (int i = 1; i <= n; i++) { int z; cin >> z; c[i] = c[i - 1] + z; } long long int res = 0, h = 0; for (int i = 45; i >= 0; i--) { if (x == 1) { for (int j = 1; j <= n; j++) { f[j] = 1e9; } for (int j = 0; j < n; j++) { for (int k = j + 1; k <= n; k++) { long long int l = c[k] - c[j]; if ((l & h) || (l & (1ll << i))) continue; f[k] = min(f[k], f[j] + 1); } } if (f[n] <= y) { h += (1ll << i); } else res += (1ll << i); } else { for (int j = 1; j <= n; j++) { for (int k = 0; k <= n; k++) { d[j][k] = 0; } } d[0][0] = 1; for (int j = 0; j < n; j++) { for (int k = j + 1; k <= n; k++) { for (int g = 0; g < n; g++) { if (d[j][g] == 0) continue; long long int l = c[k] - c[j]; if ((l & h) || (l & (1ll << i))) continue; d[k][g + 1] = 1; } } } int fl = 0; for (int j = x; j <= y; j++) { if (d[n][j] == 1) { fl = 1; } } if (fl == 1) { h += (1ll << i); } else res += (1ll << i); } } cout << res; }
#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...