This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#define int long long
using namespace std;
const int MAX_NB = 1e5+42, MAX_BLOC = 101, INF = 1e9;
int nbNombre, blocRequis;
int nombre[MAX_NB];
int dp[MAX_NB][MAX_BLOC];
signed main() {
cin >> nbNombre >> blocRequis;
for(int i = 0; i < nbNombre; i++) {
for(int j = 0; j < blocRequis; j++) dp[i][j] = INF;
}
for(int cur = 0; cur < nbNombre; cur++) {
cin >> nombre[cur];
dp[cur][0] = nombre[cur];
if(cur > 0)
dp[cur][0] = max(dp[cur][0], dp[cur-1][0]);
}
for(int nbBloc = 1; nbBloc < blocRequis; nbBloc++) {
for(int cur = nbBloc; cur < nbNombre; cur++) {
int maxi = 0;
for(int preced = cur; preced > 0; preced--) {
maxi = max(maxi, nombre[preced]);
dp[cur][nbBloc] = min(dp[cur][nbBloc], dp[preced-1][nbBloc-1] + maxi);
}
}
}
cout << dp[nbNombre-1][blocRequis-1];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |