Submission #151749

# Submission time Handle Problem Language Result Execution time Memory
151749 2019-09-04T14:05:42 Z arnold518 None (KOI17_cook) C++14
100 / 100
766 ms 50516 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 3000;

int N, M, S, E, T, A[MAXN+10][MAXN+10], B[MAXN+10];
int dp[MAXN+10][MAXN+10], ans=2147483647;
deque<pii> DQ[MAXN+10];

int main()
{
    int i, j;

    scanf("%d%d%d%d%d", &N, &M, &S, &E, &T);
    for(i=1; i<=N; i++) for(j=1; j<=M; j++) scanf("%d", &A[i][j]);
    for(i=1; i<=N; i++) for(j=M; j>=0; j--) A[i][j]+=A[i][j+1];
    for(i=1; i<=N; i++) scanf("%d", &B[i]);

    for(i=2; i<=S; i++) for(j=1; j<=N; j++) dp[j][i]=11e7;
    for(i=S+1; i<=M+1; i++)
    {
        priority_queue<pii> PQ;
        vector<pii> V;
        for(j=1; j<=N; j++)
        {
            while(!DQ[j].empty() && DQ[j].front().second<i-E) DQ[j].pop_front();
            while(!DQ[j].empty() && DQ[j].back().first>=A[j][i-S]+dp[j][i-S]) DQ[j].pop_back();
            DQ[j].push_back({dp[j][i-S]+A[j][i-S], i-S});
            PQ.push({DQ[j].front().first-A[j][i], j});
            while(PQ.size()>3) PQ.pop();
        }
        while(!PQ.empty()) V.push_back(PQ.top()), PQ.pop();
        sort(V.begin(), V.end());
        for(j=1; j<=N; j++)
        {
            for(auto it : V)
            {
                if(it.second==j || it.second==B[j]) continue;
                dp[j][i]=it.first+T;
                break;
            }
        }
    }

    for(i=M-E+1; i<=M; i++) for(j=1; j<=N; j++) ans=min(ans, dp[j][i]+A[j][i]);
    printf("%d", ans);
}

Compilation message

cook.cpp: In function 'int main()':
cook.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d%d", &N, &M, &S, &E, &T);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cook.cpp:19:50: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=N; i++) for(j=1; j<=M; j++) scanf("%d", &A[i][j]);
                                             ~~~~~^~~~~~~~~~~~~~~~
cook.cpp:21:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=N; i++) scanf("%d", &B[i]);
                         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2824 KB Output is correct
2 Correct 5 ms 2808 KB Output is correct
3 Correct 5 ms 2812 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 5 ms 2808 KB Output is correct
6 Correct 5 ms 2808 KB Output is correct
7 Correct 13 ms 2808 KB Output is correct
8 Correct 5 ms 2808 KB Output is correct
9 Correct 4 ms 2808 KB Output is correct
10 Correct 5 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2824 KB Output is correct
2 Correct 5 ms 2808 KB Output is correct
3 Correct 5 ms 2812 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 5 ms 2808 KB Output is correct
6 Correct 5 ms 2808 KB Output is correct
7 Correct 13 ms 2808 KB Output is correct
8 Correct 5 ms 2808 KB Output is correct
9 Correct 4 ms 2808 KB Output is correct
10 Correct 24 ms 6008 KB Output is correct
11 Correct 18 ms 5496 KB Output is correct
12 Correct 25 ms 6164 KB Output is correct
13 Correct 22 ms 5624 KB Output is correct
14 Correct 20 ms 6008 KB Output is correct
15 Correct 22 ms 5880 KB Output is correct
16 Correct 24 ms 6136 KB Output is correct
17 Correct 15 ms 4728 KB Output is correct
18 Correct 22 ms 6000 KB Output is correct
19 Correct 15 ms 4900 KB Output is correct
20 Correct 5 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2824 KB Output is correct
2 Correct 5 ms 2808 KB Output is correct
3 Correct 5 ms 2812 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 5 ms 2808 KB Output is correct
6 Correct 5 ms 2808 KB Output is correct
7 Correct 13 ms 2808 KB Output is correct
8 Correct 5 ms 2808 KB Output is correct
9 Correct 4 ms 2808 KB Output is correct
10 Correct 24 ms 6008 KB Output is correct
11 Correct 18 ms 5496 KB Output is correct
12 Correct 25 ms 6164 KB Output is correct
13 Correct 22 ms 5624 KB Output is correct
14 Correct 20 ms 6008 KB Output is correct
15 Correct 22 ms 5880 KB Output is correct
16 Correct 24 ms 6136 KB Output is correct
17 Correct 15 ms 4728 KB Output is correct
18 Correct 22 ms 6000 KB Output is correct
19 Correct 15 ms 4900 KB Output is correct
20 Correct 217 ms 34296 KB Output is correct
21 Correct 282 ms 34308 KB Output is correct
22 Correct 241 ms 34296 KB Output is correct
23 Correct 219 ms 34296 KB Output is correct
24 Correct 187 ms 34428 KB Output is correct
25 Correct 253 ms 34348 KB Output is correct
26 Correct 251 ms 34232 KB Output is correct
27 Correct 203 ms 34280 KB Output is correct
28 Correct 260 ms 34256 KB Output is correct
29 Correct 186 ms 34288 KB Output is correct
30 Correct 5 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2824 KB Output is correct
2 Correct 5 ms 2808 KB Output is correct
3 Correct 5 ms 2812 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 5 ms 2808 KB Output is correct
6 Correct 5 ms 2808 KB Output is correct
7 Correct 13 ms 2808 KB Output is correct
8 Correct 5 ms 2808 KB Output is correct
9 Correct 4 ms 2808 KB Output is correct
10 Correct 24 ms 6008 KB Output is correct
11 Correct 18 ms 5496 KB Output is correct
12 Correct 25 ms 6164 KB Output is correct
13 Correct 22 ms 5624 KB Output is correct
14 Correct 20 ms 6008 KB Output is correct
15 Correct 22 ms 5880 KB Output is correct
16 Correct 24 ms 6136 KB Output is correct
17 Correct 15 ms 4728 KB Output is correct
18 Correct 22 ms 6000 KB Output is correct
19 Correct 15 ms 4900 KB Output is correct
20 Correct 190 ms 10232 KB Output is correct
21 Correct 179 ms 10232 KB Output is correct
22 Correct 183 ms 10128 KB Output is correct
23 Correct 138 ms 10224 KB Output is correct
24 Correct 186 ms 10232 KB Output is correct
25 Correct 175 ms 10184 KB Output is correct
26 Correct 182 ms 10220 KB Output is correct
27 Correct 180 ms 10176 KB Output is correct
28 Correct 183 ms 10360 KB Output is correct
29 Correct 165 ms 10232 KB Output is correct
30 Correct 5 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2824 KB Output is correct
2 Correct 5 ms 2808 KB Output is correct
3 Correct 5 ms 2812 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 5 ms 2808 KB Output is correct
6 Correct 5 ms 2808 KB Output is correct
7 Correct 13 ms 2808 KB Output is correct
8 Correct 5 ms 2808 KB Output is correct
9 Correct 4 ms 2808 KB Output is correct
10 Correct 24 ms 6008 KB Output is correct
11 Correct 18 ms 5496 KB Output is correct
12 Correct 25 ms 6164 KB Output is correct
13 Correct 22 ms 5624 KB Output is correct
14 Correct 20 ms 6008 KB Output is correct
15 Correct 22 ms 5880 KB Output is correct
16 Correct 24 ms 6136 KB Output is correct
17 Correct 15 ms 4728 KB Output is correct
18 Correct 22 ms 6000 KB Output is correct
19 Correct 15 ms 4900 KB Output is correct
20 Correct 217 ms 34296 KB Output is correct
21 Correct 282 ms 34308 KB Output is correct
22 Correct 241 ms 34296 KB Output is correct
23 Correct 219 ms 34296 KB Output is correct
24 Correct 187 ms 34428 KB Output is correct
25 Correct 253 ms 34348 KB Output is correct
26 Correct 251 ms 34232 KB Output is correct
27 Correct 203 ms 34280 KB Output is correct
28 Correct 260 ms 34256 KB Output is correct
29 Correct 186 ms 34288 KB Output is correct
30 Correct 190 ms 10232 KB Output is correct
31 Correct 179 ms 10232 KB Output is correct
32 Correct 183 ms 10128 KB Output is correct
33 Correct 138 ms 10224 KB Output is correct
34 Correct 186 ms 10232 KB Output is correct
35 Correct 175 ms 10184 KB Output is correct
36 Correct 182 ms 10220 KB Output is correct
37 Correct 180 ms 10176 KB Output is correct
38 Correct 183 ms 10360 KB Output is correct
39 Correct 165 ms 10232 KB Output is correct
40 Correct 267 ms 12620 KB Output is correct
41 Correct 704 ms 26956 KB Output is correct
42 Correct 685 ms 26744 KB Output is correct
43 Correct 766 ms 50516 KB Output is correct
44 Correct 301 ms 14780 KB Output is correct
45 Correct 337 ms 17132 KB Output is correct
46 Correct 388 ms 19976 KB Output is correct
47 Correct 426 ms 24364 KB Output is correct
48 Correct 720 ms 26448 KB Output is correct
49 Correct 752 ms 26488 KB Output is correct
50 Correct 5 ms 2680 KB Output is correct