Submission #932501

#TimeUsernameProblemLanguageResultExecution timeMemory
932501vjudge1Bali Sculptures (APIO15_sculpture)C++17
50 / 100
80 ms500 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 2e3 + 5; int n, u, v; int a[N]; ll pre[N]; bool ck(ll a, ll b, ll c){ return (a | b) < (b | c); } namespace sub1{ int dp[N]; void solve(){ ll ans = 0; for (ll i = 45; i >= 0; -- i){ ll cur = (1ll << i); for (int j = 1; j <= n; ++ j){ dp[j] = n + 1; for (int k = j - 1; k >= 0; -- k){ if (ck(pre[j] - pre[k], ans, cur)) dp[j] = min(dp[j], dp[k] + 1); } } if (dp[n] > v) ans += cur; } cout << ans; } } namespace sub2{ bool dp[105][105]; void solve(){ ll ans = 0; for (ll i = 45; i >= 0; -- i){ ll cur = 1ll << i; dp[0][0] = 1; for (int j = 1; j <= n; ++ j){ for (int t = 0; t <= j; ++ t) dp[j][t] = 0; for (int k = 0; k < j; ++ k){ if (ck(pre[j] - pre[k], ans, cur)){ for (int t = 0; t <= k; ++ t) dp[j][t + 1] |= dp[k][j]; } } } bool ck = false; for (int t = u; t <= v; ++ t) if (dp[n][t]) ck = true; if (!ck) ans += cur; } cout << ans; } } void solve(){ cin >> n >> u >> v; for (int i = 1; i <= n; ++ i) cin >> a[i], pre[i] = pre[i - 1] + a[i]; if (u == 1) sub1::solve(); else sub2::solve(); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); return 0; }
#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...