Submission #733574

#TimeUsernameProblemLanguageResultExecution timeMemory
733574SanguineChameleonBali Sculptures (APIO15_sculpture)C++17
71 / 100
94 ms536 KiB
#include <bits/stdc++.h> using namespace std; void just_do_it(); int main() { #ifdef KAMIRULEZ freopen("kamirulez.inp", "r", stdin); freopen("kamirulez.out", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); just_do_it(); return 0; } const int maxN = 2e3 + 20; int a[maxN]; bool can[maxN][maxN]; int dp[maxN]; void just_do_it() { int N, A, B; cin >> N >> A >> B; for (int i = 1; i <= N; i++) { cin >> a[i]; } if (A > 1) { long long pref = 0; long long res = 0; for (int b = 39; b >= 0; b--) { pref |= (1LL << b); for (int i = 0; i <= N; i++) { for (int j = 0; j <= N; j++) { can[i][j] = false; } } can[0][0] = true; for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { long long S = 0; for (int k = i; k >= 1; k--) { S += a[k]; if (((S & pref) | res) == res) { can[i][j] |= can[k - 1][j - 1]; } } } } bool ok = false; for (int j = A; j <= B; j++) { ok |= can[N][j]; } if (!ok) { res |= (1LL << b); } } cout << res; } else { long long pref = 0; long long res = 0; for (int b = 39; b >= 0; b--) { pref |= (1LL << b); for (int i = 1; i <= N; i++) { dp[i] = N + 1; } dp[0] = 0; for (int i = 1; i <= N; i++) { long long S = 0; for (int j = i; j >= 1; j--) { S += a[j]; if (((S & pref) | res) == res) { dp[i] = min(dp[i], dp[j - 1] + 1); } } } if (dp[N] > B) { res |= (1LL << b); } } 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...