# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
151748 | 2019-09-04T14:03:19 Z | arnold518 | 요리 강좌 (KOI17_cook) | C++14 | 819 ms | 66396 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++) { 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}); V.push_back({DQ[j].front().first-A[j][i], j}); } 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2808 KB | Output is correct |
2 | Correct | 5 ms | 2808 KB | Output is correct |
3 | Correct | 5 ms | 2808 KB | Output is correct |
4 | Correct | 4 ms | 2552 KB | Output is correct |
5 | Correct | 5 ms | 2808 KB | Output is correct |
6 | Correct | 5 ms | 2808 KB | Output is correct |
7 | Correct | 4 ms | 2808 KB | Output is correct |
8 | Correct | 5 ms | 2808 KB | Output is correct |
9 | Correct | 5 ms | 2808 KB | Output is correct |
10 | Correct | 5 ms | 2684 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2808 KB | Output is correct |
2 | Correct | 5 ms | 2808 KB | Output is correct |
3 | Correct | 5 ms | 2808 KB | Output is correct |
4 | Correct | 4 ms | 2552 KB | Output is correct |
5 | Correct | 5 ms | 2808 KB | Output is correct |
6 | Correct | 5 ms | 2808 KB | Output is correct |
7 | Correct | 4 ms | 2808 KB | Output is correct |
8 | Correct | 5 ms | 2808 KB | Output is correct |
9 | Correct | 5 ms | 2808 KB | Output is correct |
10 | Correct | 25 ms | 6008 KB | Output is correct |
11 | Correct | 20 ms | 5624 KB | Output is correct |
12 | Correct | 26 ms | 6096 KB | Output is correct |
13 | Correct | 19 ms | 5496 KB | Output is correct |
14 | Correct | 22 ms | 6008 KB | Output is correct |
15 | Correct | 23 ms | 5880 KB | Output is correct |
16 | Correct | 26 ms | 6008 KB | Output is correct |
17 | Correct | 15 ms | 4856 KB | Output is correct |
18 | Correct | 22 ms | 6008 KB | Output is correct |
19 | Correct | 15 ms | 4728 KB | Output is correct |
20 | Correct | 5 ms | 2684 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2808 KB | Output is correct |
2 | Correct | 5 ms | 2808 KB | Output is correct |
3 | Correct | 5 ms | 2808 KB | Output is correct |
4 | Correct | 4 ms | 2552 KB | Output is correct |
5 | Correct | 5 ms | 2808 KB | Output is correct |
6 | Correct | 5 ms | 2808 KB | Output is correct |
7 | Correct | 4 ms | 2808 KB | Output is correct |
8 | Correct | 5 ms | 2808 KB | Output is correct |
9 | Correct | 5 ms | 2808 KB | Output is correct |
10 | Correct | 25 ms | 6008 KB | Output is correct |
11 | Correct | 20 ms | 5624 KB | Output is correct |
12 | Correct | 26 ms | 6096 KB | Output is correct |
13 | Correct | 19 ms | 5496 KB | Output is correct |
14 | Correct | 22 ms | 6008 KB | Output is correct |
15 | Correct | 23 ms | 5880 KB | Output is correct |
16 | Correct | 26 ms | 6008 KB | Output is correct |
17 | Correct | 15 ms | 4856 KB | Output is correct |
18 | Correct | 22 ms | 6008 KB | Output is correct |
19 | Correct | 15 ms | 4728 KB | Output is correct |
20 | Correct | 230 ms | 38544 KB | Output is correct |
21 | Correct | 284 ms | 38444 KB | Output is correct |
22 | Correct | 267 ms | 38524 KB | Output is correct |
23 | Correct | 225 ms | 38452 KB | Output is correct |
24 | Correct | 190 ms | 38544 KB | Output is correct |
25 | Correct | 278 ms | 38392 KB | Output is correct |
26 | Correct | 280 ms | 38444 KB | Output is correct |
27 | Correct | 214 ms | 38512 KB | Output is correct |
28 | Correct | 271 ms | 38448 KB | Output is correct |
29 | Correct | 188 ms | 38440 KB | Output is correct |
30 | Correct | 5 ms | 2684 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2808 KB | Output is correct |
2 | Correct | 5 ms | 2808 KB | Output is correct |
3 | Correct | 5 ms | 2808 KB | Output is correct |
4 | Correct | 4 ms | 2552 KB | Output is correct |
5 | Correct | 5 ms | 2808 KB | Output is correct |
6 | Correct | 5 ms | 2808 KB | Output is correct |
7 | Correct | 4 ms | 2808 KB | Output is correct |
8 | Correct | 5 ms | 2808 KB | Output is correct |
9 | Correct | 5 ms | 2808 KB | Output is correct |
10 | Correct | 25 ms | 6008 KB | Output is correct |
11 | Correct | 20 ms | 5624 KB | Output is correct |
12 | Correct | 26 ms | 6096 KB | Output is correct |
13 | Correct | 19 ms | 5496 KB | Output is correct |
14 | Correct | 22 ms | 6008 KB | Output is correct |
15 | Correct | 23 ms | 5880 KB | Output is correct |
16 | Correct | 26 ms | 6008 KB | Output is correct |
17 | Correct | 15 ms | 4856 KB | Output is correct |
18 | Correct | 22 ms | 6008 KB | Output is correct |
19 | Correct | 15 ms | 4728 KB | Output is correct |
20 | Correct | 212 ms | 14392 KB | Output is correct |
21 | Correct | 197 ms | 14344 KB | Output is correct |
22 | Correct | 209 ms | 14344 KB | Output is correct |
23 | Correct | 139 ms | 14320 KB | Output is correct |
24 | Correct | 210 ms | 14536 KB | Output is correct |
25 | Correct | 175 ms | 14316 KB | Output is correct |
26 | Correct | 206 ms | 14252 KB | Output is correct |
27 | Correct | 208 ms | 14284 KB | Output is correct |
28 | Correct | 210 ms | 14504 KB | Output is correct |
29 | Correct | 177 ms | 14372 KB | Output is correct |
30 | Correct | 5 ms | 2684 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2808 KB | Output is correct |
2 | Correct | 5 ms | 2808 KB | Output is correct |
3 | Correct | 5 ms | 2808 KB | Output is correct |
4 | Correct | 4 ms | 2552 KB | Output is correct |
5 | Correct | 5 ms | 2808 KB | Output is correct |
6 | Correct | 5 ms | 2808 KB | Output is correct |
7 | Correct | 4 ms | 2808 KB | Output is correct |
8 | Correct | 5 ms | 2808 KB | Output is correct |
9 | Correct | 5 ms | 2808 KB | Output is correct |
10 | Correct | 25 ms | 6008 KB | Output is correct |
11 | Correct | 20 ms | 5624 KB | Output is correct |
12 | Correct | 26 ms | 6096 KB | Output is correct |
13 | Correct | 19 ms | 5496 KB | Output is correct |
14 | Correct | 22 ms | 6008 KB | Output is correct |
15 | Correct | 23 ms | 5880 KB | Output is correct |
16 | Correct | 26 ms | 6008 KB | Output is correct |
17 | Correct | 15 ms | 4856 KB | Output is correct |
18 | Correct | 22 ms | 6008 KB | Output is correct |
19 | Correct | 15 ms | 4728 KB | Output is correct |
20 | Correct | 230 ms | 38544 KB | Output is correct |
21 | Correct | 284 ms | 38444 KB | Output is correct |
22 | Correct | 267 ms | 38524 KB | Output is correct |
23 | Correct | 225 ms | 38452 KB | Output is correct |
24 | Correct | 190 ms | 38544 KB | Output is correct |
25 | Correct | 278 ms | 38392 KB | Output is correct |
26 | Correct | 280 ms | 38444 KB | Output is correct |
27 | Correct | 214 ms | 38512 KB | Output is correct |
28 | Correct | 271 ms | 38448 KB | Output is correct |
29 | Correct | 188 ms | 38440 KB | Output is correct |
30 | Correct | 212 ms | 14392 KB | Output is correct |
31 | Correct | 197 ms | 14344 KB | Output is correct |
32 | Correct | 209 ms | 14344 KB | Output is correct |
33 | Correct | 139 ms | 14320 KB | Output is correct |
34 | Correct | 210 ms | 14536 KB | Output is correct |
35 | Correct | 175 ms | 14316 KB | Output is correct |
36 | Correct | 206 ms | 14252 KB | Output is correct |
37 | Correct | 208 ms | 14284 KB | Output is correct |
38 | Correct | 210 ms | 14504 KB | Output is correct |
39 | Correct | 177 ms | 14372 KB | Output is correct |
40 | Correct | 292 ms | 18424 KB | Output is correct |
41 | Correct | 774 ms | 42332 KB | Output is correct |
42 | Correct | 787 ms | 42308 KB | Output is correct |
43 | Correct | 819 ms | 66396 KB | Output is correct |
44 | Correct | 326 ms | 22448 KB | Output is correct |
45 | Correct | 354 ms | 26308 KB | Output is correct |
46 | Correct | 401 ms | 30744 KB | Output is correct |
47 | Correct | 437 ms | 38264 KB | Output is correct |
48 | Correct | 773 ms | 42248 KB | Output is correct |
49 | Correct | 760 ms | 42276 KB | Output is correct |
50 | Correct | 5 ms | 2684 KB | Output is correct |