Submission #259015

#TimeUsernameProblemLanguageResultExecution timeMemory
259015my99nBali Sculptures (APIO15_sculpture)C++14
0 / 100
1 ms400 KiB
#include<bits/stdc++.h> using namespace std; int Y[1010]; long long qs[1010]; long long dp[1010][1010]; long long sum (int i, int j) { return qs[j]-qs[i-1]; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int N, A, B; cin >> N >> A >> B; for (int i = 1; i <= N; i++) { cin >> Y[i]; qs[i] = qs[i-1] + Y[i]; } for (int i = 1; i <= N; i++) { dp[1][i] = sum(1, i); // cerr << dp[1][i] << ' '; } for (int i = 2; i <= N; i++) { for (int j = i; j <= N; j++) { // split 1 - j into i partitions dp[i][j] = 1e15; for (int k = 1; k < j; k++) { dp[i][j] = min(dp[i][j], dp[i-1][k] | sum(k+1, j)); } // cerr << endl << i << ' ' << j << ' ' << dp[i][j]; } } long long ans = 1e15; for (int i = A; i <= B; i++) { ans = min(ans, dp[i][N]); } cout << ans << endl; 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...