Submission #406823

#TimeUsernameProblemLanguageResultExecution timeMemory
4068232qbingxuanBali Sculptures (APIO15_sculpture)C++14
100 / 100
256 ms384 KiB
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #ifdef local #define safe cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n" #define pary(a...) danb(#a, a) #define debug(a...) qqbx(#a, a) template <typename ...T> void qqbx(const char *s, T ...a) { int cnt = sizeof...(T); ((std::cerr << "\033[1;32m(" << s << ") = (") , ... , (std::cerr << a << (--cnt ? ", " : ")\033[0m\n"))); } template <typename T> void danb(const char *s, T L, T R) { std::cerr << "\033[1;32m[ " << s << " ] = [ "; for (int f = 0; L != R; ++L) std::cerr << (f++ ? ", " : "") << *L; std::cerr << " ]\033[0m\n"; } #else #define debug(...) ((void)0) #define safe ((void)0) #define pary(...) ((void)0) #endif // local #define all(v) begin(v),end(v) #define pb emplace_back using namespace std; using ll = int_fast64_t; const int inf = 1e9; const int mod = 1000000007; const int maxn = 2025; const int maxc = (1 << 18); ll pre[maxn], a[maxn]; int n, A, B; int mn[maxn], mx[maxn]; bool ok(ll mask) { mn[0] = mx[0] = 0; for (int i = 1; i <= n; i++) { mn[i] = inf; mx[i] = -inf; for (int j = 0; j < i; j++) if (!(mask & (pre[i] - pre[j]))) { mn[i] = min(mn[i], mn[j] + 1); mx[i] = max(mx[i], mx[j] + 1); } } return max(A, mn[n]) <= min(B, mx[n]); } signed main() { ios_base::sync_with_stdio(0), cin.tie(0); cin >> n >> A >> B; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) pre[i+1] = pre[i] + a[i]; assert(ok(0)); ll ans = 0, U = (1LL << 51) - 1; for (ll s = 1LL << 50; s; s >>= 1) if (ok(ans + s)) ans += s; cout << (U ^ 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...