# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
40519 | 2018-02-03T16:42:20 Z | Pajaraja | K개의 묶음 (IZhO14_blocks) | C++14 | 231 ms | 13980 KB |
#include <bits/stdc++.h> using namespace std; int a[100007],dp[100007],dpl[100007],minn[100007]; int main() { int n,k; scanf("%d%d",&n,&k); for(int i=1;i<=n;i++) scanf("%d",&a[i]); a[0]=1000001; for(int i=1;i<=n;i++) dpl[i]=1000000000; stack<int> st; for(int z=1;z<=k;z++) { while(!st.empty()) st.pop(); st.push(0); dp[0]=1000000000; for(int i=1;i<=n;i++) { minn[i]=1000000000; while(a[st.top()]<=a[i]) { minn[i]=min(min(minn[i],dpl[st.top()]),minn[st.top()]); st.pop(); } minn[i]=fmin(minn[i],dpl[st.top()]); dp[i]=min(dp[st.top()],minn[i]+a[i]); st.push(i); } for(int i=0;i<=n;i++) dpl[i]=dp[i]; } printf("%d",dp[n]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 248 KB | Output is correct |
2 | Correct | 1 ms | 376 KB | Output is correct |
3 | Correct | 1 ms | 564 KB | Output is correct |
4 | Correct | 1 ms | 564 KB | Output is correct |
5 | Correct | 1 ms | 564 KB | Output is correct |
6 | Correct | 1 ms | 568 KB | Output is correct |
7 | Correct | 1 ms | 572 KB | Output is correct |
8 | Correct | 2 ms | 688 KB | Output is correct |
9 | Correct | 1 ms | 688 KB | Output is correct |
10 | Correct | 1 ms | 688 KB | Output is correct |
11 | Correct | 1 ms | 688 KB | Output is correct |
12 | Correct | 2 ms | 688 KB | Output is correct |
13 | Correct | 2 ms | 688 KB | Output is correct |
14 | Correct | 2 ms | 688 KB | Output is correct |
15 | Correct | 1 ms | 688 KB | Output is correct |
16 | Correct | 1 ms | 688 KB | Output is correct |
17 | Correct | 1 ms | 688 KB | Output is correct |
18 | Correct | 1 ms | 692 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 692 KB | Output is correct |
2 | Correct | 1 ms | 696 KB | Output is correct |
3 | Correct | 1 ms | 700 KB | Output is correct |
4 | Correct | 1 ms | 704 KB | Output is correct |
5 | Correct | 1 ms | 708 KB | Output is correct |
6 | Correct | 1 ms | 712 KB | Output is correct |
7 | Correct | 1 ms | 716 KB | Output is correct |
8 | Correct | 2 ms | 720 KB | Output is correct |
9 | Correct | 1 ms | 724 KB | Output is correct |
10 | Correct | 1 ms | 728 KB | Output is correct |
11 | Correct | 2 ms | 732 KB | Output is correct |
12 | Correct | 1 ms | 736 KB | Output is correct |
13 | Correct | 1 ms | 736 KB | Output is correct |
14 | Correct | 2 ms | 852 KB | Output is correct |
15 | Correct | 1 ms | 852 KB | Output is correct |
16 | Correct | 1 ms | 852 KB | Output is correct |
17 | Correct | 1 ms | 852 KB | Output is correct |
18 | Correct | 2 ms | 852 KB | Output is correct |
19 | Correct | 1 ms | 852 KB | Output is correct |
20 | Correct | 1 ms | 852 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 852 KB | Output is correct |
2 | Correct | 1 ms | 852 KB | Output is correct |
3 | Correct | 1 ms | 852 KB | Output is correct |
4 | Correct | 1 ms | 852 KB | Output is correct |
5 | Correct | 2 ms | 852 KB | Output is correct |
6 | Correct | 2 ms | 852 KB | Output is correct |
7 | Correct | 2 ms | 852 KB | Output is correct |
8 | Correct | 1 ms | 852 KB | Output is correct |
9 | Correct | 1 ms | 852 KB | Output is correct |
10 | Correct | 1 ms | 852 KB | Output is correct |
11 | Correct | 1 ms | 852 KB | Output is correct |
12 | Correct | 1 ms | 852 KB | Output is correct |
13 | Correct | 1 ms | 852 KB | Output is correct |
14 | Correct | 1 ms | 852 KB | Output is correct |
15 | Correct | 2 ms | 852 KB | Output is correct |
16 | Correct | 2 ms | 852 KB | Output is correct |
17 | Correct | 1 ms | 852 KB | Output is correct |
18 | Correct | 2 ms | 852 KB | Output is correct |
19 | Correct | 2 ms | 852 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 976 KB | Output is correct |
2 | Correct | 10 ms | 1956 KB | Output is correct |
3 | Correct | 15 ms | 2256 KB | Output is correct |
4 | Correct | 71 ms | 2560 KB | Output is correct |
5 | Correct | 196 ms | 4112 KB | Output is correct |
6 | Correct | 22 ms | 4740 KB | Output is correct |
7 | Correct | 95 ms | 5424 KB | Output is correct |
8 | Correct | 1 ms | 5424 KB | Output is correct |
9 | Correct | 2 ms | 5424 KB | Output is correct |
10 | Correct | 2 ms | 5424 KB | Output is correct |
11 | Correct | 1 ms | 5424 KB | Output is correct |
12 | Correct | 2 ms | 5424 KB | Output is correct |
13 | Correct | 2 ms | 5424 KB | Output is correct |
14 | Correct | 27 ms | 5424 KB | Output is correct |
15 | Correct | 5 ms | 5424 KB | Output is correct |
16 | Correct | 8 ms | 5424 KB | Output is correct |
17 | Correct | 16 ms | 5424 KB | Output is correct |
18 | Correct | 15 ms | 5424 KB | Output is correct |
19 | Correct | 86 ms | 5680 KB | Output is correct |
20 | Correct | 225 ms | 7304 KB | Output is correct |
21 | Correct | 25 ms | 7936 KB | Output is correct |
22 | Correct | 110 ms | 8684 KB | Output is correct |
23 | Correct | 19 ms | 9288 KB | Output is correct |
24 | Correct | 36 ms | 10040 KB | Output is correct |
25 | Correct | 231 ms | 10716 KB | Output is correct |
26 | Correct | 2 ms | 10716 KB | Output is correct |
27 | Correct | 2 ms | 10716 KB | Output is correct |
28 | Correct | 20 ms | 10716 KB | Output is correct |
29 | Correct | 5 ms | 10716 KB | Output is correct |
30 | Correct | 7 ms | 10716 KB | Output is correct |
31 | Correct | 8 ms | 10716 KB | Output is correct |
32 | Correct | 13 ms | 10724 KB | Output is correct |
33 | Correct | 66 ms | 11160 KB | Output is correct |
34 | Correct | 185 ms | 12616 KB | Output is correct |
35 | Correct | 21 ms | 13296 KB | Output is correct |
36 | Correct | 95 ms | 13980 KB | Output is correct |
37 | Correct | 4 ms | 13980 KB | Output is correct |
38 | Correct | 23 ms | 13980 KB | Output is correct |
39 | Correct | 2 ms | 13980 KB | Output is correct |
40 | Correct | 2 ms | 13980 KB | Output is correct |
41 | Correct | 2 ms | 13980 KB | Output is correct |
42 | Correct | 2 ms | 13980 KB | Output is correct |