Submission #13067

# Submission time Handle Problem Language Result Execution time Memory
13067 2015-01-29T17:16:15 Z dohyun0324 K blocks (IZhO14_blocks) C++
0 / 100
0 ms 45620 KB
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,k,a[100010],w,top,d[110][100010];
struct data{
    int x,gap,p;
}st[100010];
int main()
{
    int i,j;
    scanf("%d %d",&n,&k);
    for(i=1;i<=n;i++) scanf("%d",&a[i]);
    for(i=1;i<=n;i++) d[1][i]=max(d[1][i-1],a[i]);
    for(i=2;i<=k;i++)
    {
        st[0].p=i-1; top=0; st[0].gap=2147483647;
        for(j=i;j<=n;j++)
        {
            while(st[top].x<=a[j] && top>0) top--;
            top++;
            st[top].p=j; st[top].x=a[j];
            st[top].gap=min(st[top-1].gap,d[i-1][st[top-1].p]+st[top].x);
            d[i][j]=st[top].gap;
        }
    }
    printf("%d",d[k][n]);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 45620 KB Output is correct
2 Correct 0 ms 45620 KB Output is correct
3 Correct 0 ms 45620 KB Output is correct
4 Correct 0 ms 45620 KB Output is correct
5 Correct 0 ms 45620 KB Output is correct
6 Correct 0 ms 45620 KB Output is correct
7 Correct 0 ms 45620 KB Output is correct
8 Correct 0 ms 45620 KB Output is correct
9 Incorrect 0 ms 45620 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -