Submission #787437

#TimeUsernameProblemLanguageResultExecution timeMemory
787437acatmeowmeowBali Sculptures (APIO15_sculpture)C++11
71 / 100
36 ms468 KiB
#include <bits/stdc++.h> using namespace std; #define int long long namespace sub4 { const int N = 100; int prefix[N + 5]; bool dp[N + 5][N + 5]; int ans = 0; void main(int n, int a, int b, int arr[]) { for (int i = 1; i <= n; i++) prefix[i] = prefix[i - 1] + arr[i]; for (int bit = 40; bit >= 0; bit--) { for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { dp[i][j] = false; } } dp[0][0] = true; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { for (int k = 1; k <= i; k++) { int v = prefix[i] - prefix[k - 1]; if (((v >> bit) | (ans >> bit)) != (ans >> bit)) continue; dp[i][j] |= dp[k - 1][j - 1]; } } } bool valid = false; for (int j = a; j <= b; j++) valid |= dp[n][j]; if (!valid) ans ^= (1ll << bit); } cout << ans << '\n'; } } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, a, b; cin >> n >> a >> b; int arr[n + 5]; for (int i = 1; i <= n; i++)cin >> arr[i]; sub4::main(n, a, b, arr); 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...