Submission #463886

#TimeUsernameProblemLanguageResultExecution timeMemory
463886Hamed5001Bali Sculptures (APIO15_sculpture)C++14
37 / 100
126 ms16208 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mxN = 2e3+10; int dp1[mxN][mxN], dp2[mxN]; int N, A, B; int Y[mxN]; ll msk, ans; int fun2(int idx, int grp) { if (grp > B) return 0; if (idx == N) return (A <= grp && grp <= B); int &ret = dp1[idx][grp]; if (~ret) return ret; ret = 0; ll sum = 0; for (int i = idx; i < N; ++i) { sum += Y[i]; if (!(sum & msk)) ret |= fun2(i+1, grp+1); } return ret; } bool check2() { memset(dp1, -1, sizeof dp1); return fun2(0, 0); } // void solve1() { // for (int bit = 50; bit >= 0; --bit) { // msk |= (1 << bit); // if (!check1()) // msk ^= (1 << bit), ans |= (1 << bit); // } // } void solve2() { for (int bit = 50; bit >= 0; --bit) { msk |= (1 << bit); if (!check2()) msk ^= (1 << bit), ans |= (1 << bit); } cout << ans << endl; } void solve() { cin >> N >> A >> B; for (int i = 0; i < N; ++i) cin >> Y[i]; // if (A == 1) { // solve1(); // } // else { solve2(); // } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); solve(); }
#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...