# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
159548 | 2019-10-23T07:41:02 Z | DrSwad | K개의 묶음 (IZhO14_blocks) | C++17 | 51 ms | 42212 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int K = 105; const int INF = 1e9; int n, k; int a[N]; int l[N]; int dp[N][K]; int main() { // freopen("in", "r", stdin); // freopen("out", "w", stdout); cin >> n >> k; for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 2; i <= n; i++) { int at = i - 1; while (at > 0 && a[at] < a[i]) at = l[at]; l[i] = at; } fill(&dp[0][0], &dp[N][0], INF); dp[0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= k; j++) { dp[i][j] = min(a[i] + dp[min(max(l[i], j - 1), i - 1)][j - 1], dp[l[i]][j]); } } cout << dp[n][k] << endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 41464 KB | Output is correct |
2 | Correct | 36 ms | 41464 KB | Output is correct |
3 | Correct | 37 ms | 41464 KB | Output is correct |
4 | Correct | 36 ms | 41464 KB | Output is correct |
5 | Correct | 36 ms | 41456 KB | Output is correct |
6 | Correct | 36 ms | 41464 KB | Output is correct |
7 | Correct | 37 ms | 41464 KB | Output is correct |
8 | Correct | 36 ms | 41464 KB | Output is correct |
9 | Correct | 39 ms | 41536 KB | Output is correct |
10 | Correct | 36 ms | 41464 KB | Output is correct |
11 | Correct | 38 ms | 41592 KB | Output is correct |
12 | Correct | 36 ms | 41468 KB | Output is correct |
13 | Incorrect | 41 ms | 41464 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 41464 KB | Output is correct |
2 | Correct | 36 ms | 41428 KB | Output is correct |
3 | Correct | 36 ms | 41464 KB | Output is correct |
4 | Correct | 36 ms | 41464 KB | Output is correct |
5 | Correct | 36 ms | 41464 KB | Output is correct |
6 | Correct | 36 ms | 41464 KB | Output is correct |
7 | Correct | 36 ms | 41464 KB | Output is correct |
8 | Correct | 36 ms | 41464 KB | Output is correct |
9 | Correct | 37 ms | 41468 KB | Output is correct |
10 | Correct | 37 ms | 41464 KB | Output is correct |
11 | Correct | 37 ms | 41464 KB | Output is correct |
12 | Incorrect | 37 ms | 41464 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 36 ms | 41396 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 41596 KB | Output is correct |
2 | Correct | 45 ms | 42212 KB | Output is correct |
3 | Correct | 45 ms | 42108 KB | Output is correct |
4 | Incorrect | 51 ms | 42104 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |