Submission #13069

# Submission time Handle Problem Language Result Execution time Memory
13069 2015-01-29T18:20:46 Z dohyun0324 K blocks (IZhO14_blocks) C++
100 / 100
170 ms 45620 KB
#include<stdio.h>
#include<algorithm>
using namespace std;
int mini,n,k,a[100010],top,d[110][100010];
struct data{
    int x,mini,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++){
        top=0; d[i][0]=2147483647;
        for(j=i;j<=n;j++){
            mini=2147483647;
            while(st[top].x<=a[j] && top>0){
                mini=min(mini,st[top].mini);
                top--;
            }
            top++;
            st[top].mini=min(mini,d[i-1][j-1]);
            d[i][j]=min(d[i][st[top-1].p],st[top].mini+a[j]);
            st[top].x=a[j]; st[top].p=j;
        }
    }
    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 Correct 0 ms 45620 KB Output is correct
10 Correct 0 ms 45620 KB Output is correct
11 Correct 0 ms 45620 KB Output is correct
12 Correct 0 ms 45620 KB Output is correct
13 Correct 0 ms 45620 KB Output is correct
14 Correct 0 ms 45620 KB Output is correct
15 Correct 0 ms 45620 KB Output is correct
16 Correct 0 ms 45620 KB Output is correct
17 Correct 0 ms 45620 KB Output is correct
18 Correct 0 ms 45620 KB Output is correct
# 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 Correct 0 ms 45620 KB Output is correct
10 Correct 0 ms 45620 KB Output is correct
11 Correct 0 ms 45620 KB Output is correct
12 Correct 0 ms 45620 KB Output is correct
13 Correct 0 ms 45620 KB Output is correct
14 Correct 0 ms 45620 KB Output is correct
15 Correct 0 ms 45620 KB Output is correct
16 Correct 0 ms 45620 KB Output is correct
17 Correct 0 ms 45620 KB Output is correct
18 Correct 0 ms 45620 KB Output is correct
19 Correct 0 ms 45620 KB Output is correct
20 Correct 0 ms 45620 KB Output is correct
# 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 Correct 0 ms 45620 KB Output is correct
10 Correct 0 ms 45620 KB Output is correct
11 Correct 0 ms 45620 KB Output is correct
12 Correct 1 ms 45620 KB Output is correct
13 Correct 0 ms 45620 KB Output is correct
14 Correct 0 ms 45620 KB Output is correct
15 Correct 0 ms 45620 KB Output is correct
16 Correct 0 ms 45620 KB Output is correct
17 Correct 0 ms 45620 KB Output is correct
18 Correct 0 ms 45620 KB Output is correct
19 Correct 0 ms 45620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 45620 KB Output is correct
2 Correct 5 ms 45620 KB Output is correct
3 Correct 6 ms 45620 KB Output is correct
4 Correct 49 ms 45620 KB Output is correct
5 Correct 135 ms 45620 KB Output is correct
6 Correct 23 ms 45620 KB Output is correct
7 Correct 68 ms 45620 KB Output is correct
8 Correct 0 ms 45620 KB Output is correct
9 Correct 0 ms 45620 KB Output is correct
10 Correct 0 ms 45620 KB Output is correct
11 Correct 0 ms 45620 KB Output is correct
12 Correct 0 ms 45620 KB Output is correct
13 Correct 0 ms 45620 KB Output is correct
14 Correct 15 ms 45620 KB Output is correct
15 Correct 0 ms 45620 KB Output is correct
16 Correct 0 ms 45620 KB Output is correct
17 Correct 8 ms 45620 KB Output is correct
18 Correct 0 ms 45620 KB Output is correct
19 Correct 55 ms 45620 KB Output is correct
20 Correct 167 ms 45620 KB Output is correct
21 Correct 14 ms 45620 KB Output is correct
22 Correct 84 ms 45620 KB Output is correct
23 Correct 15 ms 45620 KB Output is correct
24 Correct 32 ms 45620 KB Output is correct
25 Correct 170 ms 45620 KB Output is correct
26 Correct 0 ms 45620 KB Output is correct
27 Correct 0 ms 45620 KB Output is correct
28 Correct 19 ms 45620 KB Output is correct
29 Correct 2 ms 45620 KB Output is correct
30 Correct 3 ms 45620 KB Output is correct
31 Correct 0 ms 45620 KB Output is correct
32 Correct 13 ms 45620 KB Output is correct
33 Correct 48 ms 45620 KB Output is correct
34 Correct 143 ms 45620 KB Output is correct
35 Correct 14 ms 45620 KB Output is correct
36 Correct 72 ms 45620 KB Output is correct
37 Correct 2 ms 45620 KB Output is correct
38 Correct 20 ms 45620 KB Output is correct
39 Correct 0 ms 45620 KB Output is correct
40 Correct 0 ms 45620 KB Output is correct
41 Correct 0 ms 45620 KB Output is correct
42 Correct 0 ms 45620 KB Output is correct