| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 159548 | DrSwad | K개의 묶음 (IZhO14_blocks) | C++17 | 51 ms | 42212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
