Submission #376000

#TimeUsernameProblemLanguageResultExecution timeMemory
376000Alex_tz307Split the sequence (APIO14_sequence)C++17
0 / 100
44 ms364 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int NMAX = 2048; const int INF = 1e18L; int N, A, B, a[NMAX], dp[NMAX], ans = (1LL << 60) - 1; void min_self(int &a, int b) { a = min(a, b); } bool check() { for(int i = 1; i <= N; ++i) dp[i] = INF; for(int i = 0; i < N; ++i) { int sum = 0; for(int j = i; j < N; ++j) { sum += a[j]; if((sum | ans) == ans) min_self(dp[j + 1], dp[i] + 1); } } return dp[N] <= B; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> N >> A >> B; for(int i = 0; i < N; ++i) cin >> a[i]; for(int bit = 59; bit >= 0; --bit) { ans ^= (1LL << bit); if(!check()) ans |= (1LL << bit); } cout << ans << '\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...
#Verdict Execution timeMemoryGrader output
Fetching results...