Submission #972711

#TimeUsernameProblemLanguageResultExecution timeMemory
972711Halym2007Bali Sculptures (APIO15_sculpture)C++17
50 / 100
60 ms604 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 2e3 + 5; ll n, A, B, dp[N], a[N]; bool check (ll x) { for (int i = 1; i <= n; ++i) { dp[i] = 1e9; } for (int i = 1; i <= n; ++i) { ll sum = 0; for (int j = i; j > 0; j--) { sum += a[j]; if ((sum & x) == sum and dp[j - 1] != 1e9) { dp[i] = min (dp[i], dp[j - 1] + 1); } } } return dp[n] <= B; } int main () { // freopen ("input.txt", "r", stdin); cin >> n >> A >> B; for (int i = 1; i <= n; ++i) { cin >> a[i]; } ll x = (1LL << 42) - 1; for (int i = 41; i >= 0; i--) { x ^= (1LL << i); if (!check(x)) { x ^= (1LL << i); } } cout << x << "\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...