Submission #1084733

#TimeUsernameProblemLanguageResultExecution timeMemory
1084733MrPavlitoBali Sculptures (APIO15_sculpture)C++17
0 / 100
18 ms31908 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define sc second #define endl "\n" #define pii pair<int,int> using namespace std; const int MAXN = 2e3+5; const int mod7 = 1e9+7; const long long inf = 1e18; vector<vector<int>> dp(MAXN, vector<int>(MAXN, inf)); signed main() { ios_base::sync_with_stdio(false),cin.tie(0), cout.tie(0); int tt=1; //cin >> tt; while(tt--) { int n,a,b; cin >> n >> a >> b; vector<int>niz(n); vector<int>pref(n+1, 0); for(int i=0; i<n; i++) { cin >> niz[i]; pref[i+1] = pref[i] + niz[i]; } for(int i=0; i<n; i++)dp[1][i] = pref[i+1]; for(int i=2; i<=b; i++) { for(int j=i-1; j<n; j++) { for(int k=i-1; k<j; k++) { dp[i][j] = min(dp[i][j], dp[i-1][k]| (pref[j+1]- pref[k+1])); } } } /*for(int i=1; i<=b; i++) { for(int j=0; j<n; j++)cout << dp[i][j] << " ";cout << endl; } */ int rez = inf; for(int i=a; i<=b; i++)rez = min(rez, dp[i][n-1]); cout << rez << endl; } } /* 6 1 3 8 1 2 1 5 4 */
#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...