#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
#include <time.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
// 제대로 번역했나?
const int N_ = 100005, K_ = 20;
int N, K;
int A[N_];
int Table[N_][K_];
int main() {
scanf("%d%d", &N, &K);
for(int i = 1; i <= N; i++) scanf("%d", A+i);
for(int i = 1; i <= N; i++) {
for(int k = 1; k <= i && k <= K; k++) {
int mx = 0;
Table[i][k] = (int)1e9;
for(int j = i; j > 0; j--) {
mx = max(mx, A[j]);
if(k <= j) Table[i][k] = min(Table[i][k], Table[j - 1][k - 1] + mx);
}
}
}
printf("%d\n", Table[N][K]);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9292 KB |
Output is correct |
2 |
Incorrect |
0 ms |
9292 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9292 KB |
Output is correct |
2 |
Incorrect |
0 ms |
9292 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
9292 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
9288 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |