Submission #506733

#TimeUsernameProblemLanguageResultExecution timeMemory
506733Aldas25Bali Sculptures (APIO15_sculpture)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr) #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define REP(n) FOR(O, 1, (n)) #define pb push_back #define f first #define s second typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vii; const int MAXN = 2100; const ll INF = 1e17; int n, a, b; ll y[MAXN]; ll pref[MAXN]; ll dp[MAXN][MAXN]; int main() { FAST_IO; cin >> n >> a >> b; FOR(i, 1, n) cin >> y[i]; FOR(i, 1, n) pref[i] = pref[i-1] + y[i]; FOR(i, 0, n) FOR(g, 0, n) dp[i][g] = INF; dp[0][0] = 0; FOR(i, 1, n) FOR(g, 1, i) { FOR(j, g-1, i-1) { ll cur = dp[j][g-1] | (pref[i] - pref[j]); dp[i][g] = min(dp[i][g], cur); } //cout << " i = " << i << " g = " << g << " dp = " << dp[i][g] << endl; } ll ans = INF; FOR(x, a, b) ans = min(ans, dp[n][x]); cout << ans << "\n"; return 0; } /* in: 6 1 3 8 1 2 1 5 4 ans: 11 */
#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...