Submission #932498

#TimeUsernameProblemLanguageResultExecution timeMemory
932498vjudge1Bali Sculptures (APIO15_sculpture)C++17
50 / 100
78 ms612 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{ void solve(){ } } 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...