제출 #883143

#제출 시각아이디문제언어결과실행 시간메모리
883143serifefedartarBali Sculptures (APIO15_sculpture)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0); #define s second #define f first typedef long long ll; const ll MOD = 1e9 + 9; const ll LOGN = 21; const ll MAXN = 3000; vector<ll> arr; ll pref[MAXN], N, A, B; pair<ll,ll> dp[MAXN]; bool check(ll mid) { dp[0] = {0, 0}; for (int i = 1; i < MAXN; i++) dp[i] = {1e12, -1e12}; for (int i = 1; i <= N; i++) { for (int j = i-1; j >= 0; j--) { if ((mid | (pref[i] - pref[j])) == mid) dp[i] = {min(dp[i].f, dp[j].f + 1), max(dp[i].s, dp[j].s + 1)}; } } return (B >= dp[N].f && A <= dp[N].s); } void solve1() { ll ans = (1LL << 35) - 1; for (int bit = 34; bit >= 0; bit--) { bool ch = check(ans ^ (1LL << bit)); if (ch) ans ^= (1LL << bit); } cout << ans << "\n"; } void solve2() { } int main() { cin >> N >> A >> B; arr = vector<ll>(N+1); for (int i = 1; i <= N; i++) { cin >> arr[i]; pref[i] = pref[i-1] + arr[i]; } if (N > 100) solve1(); else solve2(); }
#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...