| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 645241 | someone | K개의 묶음 (IZhO14_blocks) | C++14 | 1 ms | 1108 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 42, K = 110, INF = 1e18 + 42;
int n, k, a[N], pre[N], dp[K][N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
n++;
a[0] = INF;
vector<int> imax(1);
for(int i = 1; i < n; i++) {
cin >> a[i];
while(a[imax.back()] < a[i])
imax.pop_back();
pre[i] = imax.back();
imax.push_back(i);
}
for(int i = 1; i < N; i++)
dp[0][i] = INF;
for(int i = 1; i <= k; i++) {
dp[i][i-1] = INF;
for(int j = i; j < n; j++) {
pre[j] = max(pre[j], i-1);
dp[i][j] = min(a[j] + dp[i-1][pre[j]], dp[i][pre[j]]);
}
}
cout << dp[k][n-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... | ||||
