답안 #5738

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
5738 2014-05-15T02:34:07 Z kriii K개의 묶음 (IZhO14_blocks) C++
100 / 100
124 ms 3040 KB
#include <stdio.h>

int N,K,A[100001],prv[100001],nxt[100001];
int P[100001],Q[100001],sz;

int main()
{
	scanf ("%d %d",&N,&K);

	for (int i=1;i<=N;i++){
		scanf ("%d",&A[i]);
		prv[i] = 0x3fffffff;
	}

	while (K--){
		P[0] = 0; Q[0] = 0x3fffffff; sz = 0;
		nxt[0] = 0x3fffffff;
		
		for (int i=1;i<=N;i++){
			int last = prv[i-1];
			while (Q[sz] <= A[i]){
				if (last > P[sz]) last = P[sz];
				sz--;
			}
			if (P[sz] + Q[sz] > last + A[i]){
				sz++; P[sz] = last; Q[sz] = A[i];
			}
			nxt[i] = P[sz] + Q[sz];
		}
		for (int i=0;i<=N;i++) prv[i] = nxt[i];
	}

	printf ("%d\n",prv[N]);

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3040 KB Output is correct
2 Correct 0 ms 3040 KB Output is correct
3 Correct 0 ms 3040 KB Output is correct
4 Correct 0 ms 3040 KB Output is correct
5 Correct 0 ms 3040 KB Output is correct
6 Correct 0 ms 3040 KB Output is correct
7 Correct 0 ms 3040 KB Output is correct
8 Correct 0 ms 3040 KB Output is correct
9 Correct 0 ms 3040 KB Output is correct
10 Correct 0 ms 3040 KB Output is correct
11 Correct 0 ms 3040 KB Output is correct
12 Correct 0 ms 3040 KB Output is correct
13 Correct 0 ms 3040 KB Output is correct
14 Correct 0 ms 3040 KB Output is correct
15 Correct 0 ms 3040 KB Output is correct
16 Correct 0 ms 3040 KB Output is correct
17 Correct 0 ms 3040 KB Output is correct
18 Correct 0 ms 3040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3040 KB Output is correct
2 Correct 0 ms 3040 KB Output is correct
3 Correct 0 ms 3040 KB Output is correct
4 Correct 0 ms 3040 KB Output is correct
5 Correct 0 ms 3040 KB Output is correct
6 Correct 0 ms 3040 KB Output is correct
7 Correct 0 ms 3040 KB Output is correct
8 Correct 0 ms 3040 KB Output is correct
9 Correct 0 ms 3040 KB Output is correct
10 Correct 0 ms 3040 KB Output is correct
11 Correct 0 ms 3040 KB Output is correct
12 Correct 0 ms 3040 KB Output is correct
13 Correct 0 ms 3040 KB Output is correct
14 Correct 0 ms 3040 KB Output is correct
15 Correct 0 ms 3040 KB Output is correct
16 Correct 0 ms 3040 KB Output is correct
17 Correct 0 ms 3040 KB Output is correct
18 Correct 0 ms 3040 KB Output is correct
19 Correct 0 ms 3040 KB Output is correct
20 Correct 0 ms 3040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3040 KB Output is correct
2 Correct 0 ms 3040 KB Output is correct
3 Correct 0 ms 3040 KB Output is correct
4 Correct 0 ms 3040 KB Output is correct
5 Correct 0 ms 3040 KB Output is correct
6 Correct 0 ms 3040 KB Output is correct
7 Correct 0 ms 3040 KB Output is correct
8 Correct 0 ms 3040 KB Output is correct
9 Correct 0 ms 3040 KB Output is correct
10 Correct 0 ms 3040 KB Output is correct
11 Correct 0 ms 3040 KB Output is correct
12 Correct 0 ms 3040 KB Output is correct
13 Correct 0 ms 3040 KB Output is correct
14 Correct 0 ms 3040 KB Output is correct
15 Correct 0 ms 3040 KB Output is correct
16 Correct 0 ms 3040 KB Output is correct
17 Correct 0 ms 3040 KB Output is correct
18 Correct 0 ms 3040 KB Output is correct
19 Correct 0 ms 3040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3040 KB Output is correct
2 Correct 0 ms 3040 KB Output is correct
3 Correct 8 ms 3040 KB Output is correct
4 Correct 36 ms 3040 KB Output is correct
5 Correct 100 ms 3040 KB Output is correct
6 Correct 12 ms 3040 KB Output is correct
7 Correct 52 ms 3040 KB Output is correct
8 Correct 0 ms 3040 KB Output is correct
9 Correct 0 ms 3040 KB Output is correct
10 Correct 0 ms 3040 KB Output is correct
11 Correct 0 ms 3040 KB Output is correct
12 Correct 0 ms 3040 KB Output is correct
13 Correct 0 ms 3040 KB Output is correct
14 Correct 8 ms 3040 KB Output is correct
15 Correct 0 ms 3040 KB Output is correct
16 Correct 4 ms 3040 KB Output is correct
17 Correct 4 ms 3040 KB Output is correct
18 Correct 8 ms 3040 KB Output is correct
19 Correct 32 ms 3040 KB Output is correct
20 Correct 84 ms 3040 KB Output is correct
21 Correct 16 ms 3040 KB Output is correct
22 Correct 36 ms 3040 KB Output is correct
23 Correct 16 ms 3040 KB Output is correct
24 Correct 16 ms 3040 KB Output is correct
25 Correct 88 ms 3040 KB Output is correct
26 Correct 0 ms 3040 KB Output is correct
27 Correct 0 ms 3040 KB Output is correct
28 Correct 12 ms 3040 KB Output is correct
29 Correct 0 ms 3040 KB Output is correct
30 Correct 4 ms 3040 KB Output is correct
31 Correct 4 ms 3040 KB Output is correct
32 Correct 8 ms 3040 KB Output is correct
33 Correct 40 ms 3040 KB Output is correct
34 Correct 124 ms 3040 KB Output is correct
35 Correct 8 ms 3040 KB Output is correct
36 Correct 64 ms 3040 KB Output is correct
37 Correct 0 ms 3040 KB Output is correct
38 Correct 8 ms 3040 KB Output is correct
39 Correct 0 ms 3040 KB Output is correct
40 Correct 0 ms 3040 KB Output is correct
41 Correct 0 ms 3040 KB Output is correct
42 Correct 0 ms 3040 KB Output is correct