답안 #89865

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
89865 2018-12-18T16:05:35 Z Bodo171 K개의 묶음 (IZhO14_blocks) C++14
100 / 100
184 ms 16120 KB
#include <iostream>
#include <fstream>
#include <climits>
using namespace std;
const int nmax=100005;
long long v[nmax],dp[2][nmax],mn[nmax],act[nmax];
int st[nmax];
int n,k,i,j,use,u;
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n>>k;
    for(i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    for(i=0;i<=n;i++)
        dp[0][i]=1LL*1e15,dp[1][i]=1LL*1e15;
    mn[0]=1LL*1e15;dp[0][0]=0;
    for(int cnt=1;cnt<=k;cnt++)
    {
        use=1-use;u=0;
        for(i=1;i<=n;i++)
        {
            act[i]=1LL*1e15;
            while(u>0&&v[i]>=v[st[u]])
            {
                act[i]=min(act[st[u]],act[i]);
                u--;
            }
            st[++u]=i;act[i]=min(act[i],dp[1-use][st[u-1]]);
            mn[u]=min(mn[u-1],1LL*act[i]+v[i]);
            dp[use][i]=1LL*mn[u];
            act[i]=min(act[i],dp[1-use][i]);
        }
        for(i=0;i<=n;i++)
            dp[1-use][i]=1LL*1e15;
    }
    cout<<dp[use][n];
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 444 KB Output is correct
3 Correct 2 ms 444 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 568 KB Output is correct
7 Correct 3 ms 572 KB Output is correct
8 Correct 2 ms 580 KB Output is correct
9 Correct 2 ms 712 KB Output is correct
10 Correct 2 ms 712 KB Output is correct
11 Correct 2 ms 712 KB Output is correct
12 Correct 2 ms 712 KB Output is correct
13 Correct 2 ms 732 KB Output is correct
14 Correct 2 ms 732 KB Output is correct
15 Correct 2 ms 732 KB Output is correct
16 Correct 2 ms 732 KB Output is correct
17 Correct 2 ms 736 KB Output is correct
18 Correct 2 ms 828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 828 KB Output is correct
2 Correct 2 ms 828 KB Output is correct
3 Correct 2 ms 828 KB Output is correct
4 Correct 2 ms 828 KB Output is correct
5 Correct 2 ms 840 KB Output is correct
6 Correct 2 ms 840 KB Output is correct
7 Correct 2 ms 840 KB Output is correct
8 Correct 2 ms 840 KB Output is correct
9 Correct 2 ms 840 KB Output is correct
10 Correct 2 ms 876 KB Output is correct
11 Correct 2 ms 1004 KB Output is correct
12 Correct 2 ms 1004 KB Output is correct
13 Correct 2 ms 1004 KB Output is correct
14 Correct 3 ms 1004 KB Output is correct
15 Correct 2 ms 1004 KB Output is correct
16 Correct 2 ms 1004 KB Output is correct
17 Correct 2 ms 1004 KB Output is correct
18 Correct 2 ms 1004 KB Output is correct
19 Correct 2 ms 1056 KB Output is correct
20 Correct 2 ms 1056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1056 KB Output is correct
2 Correct 2 ms 1108 KB Output is correct
3 Correct 2 ms 1108 KB Output is correct
4 Correct 2 ms 1108 KB Output is correct
5 Correct 2 ms 1200 KB Output is correct
6 Correct 2 ms 1200 KB Output is correct
7 Correct 2 ms 1200 KB Output is correct
8 Correct 2 ms 1200 KB Output is correct
9 Correct 2 ms 1200 KB Output is correct
10 Correct 2 ms 1200 KB Output is correct
11 Correct 2 ms 1200 KB Output is correct
12 Correct 2 ms 1200 KB Output is correct
13 Correct 2 ms 1200 KB Output is correct
14 Correct 2 ms 1200 KB Output is correct
15 Correct 2 ms 1240 KB Output is correct
16 Correct 2 ms 1240 KB Output is correct
17 Correct 2 ms 1240 KB Output is correct
18 Correct 2 ms 1240 KB Output is correct
19 Correct 2 ms 1240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1392 KB Output is correct
2 Correct 9 ms 2796 KB Output is correct
3 Correct 13 ms 3116 KB Output is correct
4 Correct 49 ms 3508 KB Output is correct
5 Correct 143 ms 5904 KB Output is correct
6 Correct 21 ms 6472 KB Output is correct
7 Correct 73 ms 7156 KB Output is correct
8 Correct 2 ms 7156 KB Output is correct
9 Correct 2 ms 7156 KB Output is correct
10 Correct 2 ms 7156 KB Output is correct
11 Correct 2 ms 7156 KB Output is correct
12 Correct 3 ms 7156 KB Output is correct
13 Correct 2 ms 7156 KB Output is correct
14 Correct 19 ms 7156 KB Output is correct
15 Correct 4 ms 7156 KB Output is correct
16 Correct 8 ms 7156 KB Output is correct
17 Correct 9 ms 7156 KB Output is correct
18 Correct 14 ms 7156 KB Output is correct
19 Correct 66 ms 7156 KB Output is correct
20 Correct 184 ms 9096 KB Output is correct
21 Correct 22 ms 9668 KB Output is correct
22 Correct 91 ms 10344 KB Output is correct
23 Correct 17 ms 11020 KB Output is correct
24 Correct 34 ms 11704 KB Output is correct
25 Correct 175 ms 12512 KB Output is correct
26 Correct 3 ms 12512 KB Output is correct
27 Correct 3 ms 12512 KB Output is correct
28 Correct 16 ms 12512 KB Output is correct
29 Correct 4 ms 12512 KB Output is correct
30 Correct 6 ms 12512 KB Output is correct
31 Correct 10 ms 12512 KB Output is correct
32 Correct 13 ms 12512 KB Output is correct
33 Correct 54 ms 12512 KB Output is correct
34 Correct 147 ms 14892 KB Output is correct
35 Correct 21 ms 15436 KB Output is correct
36 Correct 77 ms 16120 KB Output is correct
37 Correct 4 ms 16120 KB Output is correct
38 Correct 15 ms 16120 KB Output is correct
39 Correct 2 ms 16120 KB Output is correct
40 Correct 3 ms 16120 KB Output is correct
41 Correct 2 ms 16120 KB Output is correct
42 Correct 2 ms 16120 KB Output is correct