# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
5157 | ainta | K개의 묶음 (IZhO14_blocks) | C++98 | 132 ms | 41716 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<stdio.h>
int D[101][100010];
int n, m, w[100010], st[100010][2];
int main()
{
int i, j, top, x;
scanf("%d%d", &n, &m);
for (i = 1; i <= n; i++){
scanf("%d", &w[i]);
D[1][i] = w[i];
if (i > 1 && D[1][i] < D[1][i - 1])D[1][i] = D[1][i - 1];
}
for (i = 1; i < m; i++){
top = 0;
for (j = i + 1; j <= n; j++){
x = D[i][j - 1];
while (top && st[top][0] <= w[j]){
if (x>st[top][1])x = st[top][1];
top--;
}
if (!top || x + w[j] < st[top][0] + st[top][1])st[++top][0] = w[j], st[top][1] = x;
D[i + 1][j] = st[top][0] + st[top][1];
}
}
printf("%d\n", D[m][n]);
}
# | 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... |