| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 336947 | boykut | K개의 묶음 (IZhO14_blocks) | C++14 | 145 ms | 81900 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <map>
#include <vector>
#include <fstream>
using namespace std;
ifstream cin("triangles.in");
ofstream cout("triangles.out");
const int inf = 2e9;
int a[100001];
int dp[100001][101];
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
int N, K;
cin >> N >> K;
for (int i = 1; i <= N; i++) {
cin >> a[i];
}
for (int i = 0; i <= N; i++) {
for (int j = 0; j <= K; j++) {
dp[i][j] = inf;
}
}
dp[0][0] = 0;
dp[1][1] = a[1];
for (int i = 2; i <= N; i++) {
dp[i][1] = max(dp[i - 1][1], a[i]);
}
auto getmax = [&](int l, int r) -> int {
int mx = a[l];
for (int i = l; i <= r; i++) {
mx = max(a[l], a[i]);
}
return mx;
};
for (int k = 2; k <= K; k++) {
for (int i = 1; i <= N; i++) {
int first = dp[i - 1][k - 1];
for (int j = 1; j < i; j++) {
dp[i][k] = min(dp[i][k], dp[j][k - 1] + getmax(j + 1, i));
}
}
}
cout << dp[N][K] << '\n';
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... | ||||
