# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
514812 | 2022-01-18T13:56:17 Z | 79brue | None (KOI17_cook) | C++14 | 831 ms | 123928 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, m, s, e; ll t; /// m: 학원 수, n: 강좌 수 ll arr[3002][3002]; ll sum[3002][3002]; int prv[3002]; list<pair<int, ll> > lst[3002]; vector<pair<ll, int> > vec; ll DP[3002][3002]; ll ans = LLONG_MAX; int main(){ scanf("%d %d %d %d %lld", &m, &n, &s, &e, &t); for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) scanf("%lld", &arr[j][i]), sum[j][i] = sum[j-1][i] + arr[j][i]; for(int i=1; i<=m; i++) scanf("%d", &prv[i]); for(int i=1; i<=m; i++) lst[i].push_back(make_pair(-1, 1e18)); for(int i=1; i<=n; i++){ /// DP 값을 덱에 반영한다. if(i >= s){ vec.clear(); for(int j=1; j<=m; j++) vec.push_back(make_pair(DP[i-s][j], j)); sort(vec.begin(), vec.end()); for(int j=1; j<=m; j++){ int pnt = 0; while(vec[pnt].second == j || vec[pnt].second == prv[j]) pnt++; ll w = vec[pnt].first - sum[i-s][j]; int x = vec[pnt].second; while(!lst[j].empty() && lst[j].back().second >= w) lst[j].pop_back(); lst[j].push_back(make_pair(i-s, w)); } } /// DP 값을 계산한다. for(int j=1; j<=m; j++){ while(lst[j].front().first < i-e) lst[j].pop_front(); DP[i][j] = lst[j].front().second + sum[i][j] + t; if(i==n) ans = min(ans, DP[i][j] - t); } } for(int i=n-s; i<=n-1; i++){ vec.clear(); for(int j=1; j<=m; j++) vec.push_back(make_pair(DP[i][j], j)); sort(vec.begin(), vec.end()); for(int j=1; j<=m; j++){ int pnt = 0; while(vec[pnt].second == j || vec[pnt].second == prv[j]) pnt++; ll w = vec[pnt].first; int x = vec[pnt].second; ans = min(ans, w + sum[n][j] - sum[i][j]); } } printf("%lld", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 972 KB | Output is correct |
2 | Correct | 1 ms | 972 KB | Output is correct |
3 | Correct | 2 ms | 992 KB | Output is correct |
4 | Correct | 1 ms | 972 KB | Output is correct |
5 | Correct | 2 ms | 972 KB | Output is correct |
6 | Correct | 1 ms | 972 KB | Output is correct |
7 | Correct | 1 ms | 716 KB | Output is correct |
8 | Correct | 1 ms | 1032 KB | Output is correct |
9 | Correct | 1 ms | 776 KB | Output is correct |
10 | Correct | 1 ms | 1036 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 972 KB | Output is correct |
2 | Correct | 1 ms | 972 KB | Output is correct |
3 | Correct | 2 ms | 992 KB | Output is correct |
4 | Correct | 1 ms | 972 KB | Output is correct |
5 | Correct | 2 ms | 972 KB | Output is correct |
6 | Correct | 1 ms | 972 KB | Output is correct |
7 | Correct | 1 ms | 716 KB | Output is correct |
8 | Correct | 1 ms | 1032 KB | Output is correct |
9 | Correct | 1 ms | 776 KB | Output is correct |
10 | Correct | 1 ms | 1036 KB | Output is correct |
11 | Correct | 17 ms | 6656 KB | Output is correct |
12 | Correct | 13 ms | 4648 KB | Output is correct |
13 | Correct | 19 ms | 6552 KB | Output is correct |
14 | Correct | 13 ms | 4536 KB | Output is correct |
15 | Correct | 20 ms | 6728 KB | Output is correct |
16 | Correct | 23 ms | 6668 KB | Output is correct |
17 | Correct | 19 ms | 6648 KB | Output is correct |
18 | Correct | 10 ms | 5768 KB | Output is correct |
19 | Correct | 19 ms | 6648 KB | Output is correct |
20 | Correct | 11 ms | 5760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 972 KB | Output is correct |
2 | Correct | 1 ms | 972 KB | Output is correct |
3 | Correct | 2 ms | 992 KB | Output is correct |
4 | Correct | 1 ms | 972 KB | Output is correct |
5 | Correct | 2 ms | 972 KB | Output is correct |
6 | Correct | 1 ms | 972 KB | Output is correct |
7 | Correct | 1 ms | 716 KB | Output is correct |
8 | Correct | 1 ms | 1032 KB | Output is correct |
9 | Correct | 1 ms | 776 KB | Output is correct |
10 | Correct | 17 ms | 6656 KB | Output is correct |
11 | Correct | 13 ms | 4648 KB | Output is correct |
12 | Correct | 19 ms | 6552 KB | Output is correct |
13 | Correct | 13 ms | 4536 KB | Output is correct |
14 | Correct | 20 ms | 6728 KB | Output is correct |
15 | Correct | 23 ms | 6668 KB | Output is correct |
16 | Correct | 19 ms | 6648 KB | Output is correct |
17 | Correct | 10 ms | 5768 KB | Output is correct |
18 | Correct | 19 ms | 6648 KB | Output is correct |
19 | Correct | 11 ms | 5760 KB | Output is correct |
20 | Correct | 1 ms | 1036 KB | Output is correct |
21 | Correct | 185 ms | 26852 KB | Output is correct |
22 | Correct | 179 ms | 26704 KB | Output is correct |
23 | Correct | 181 ms | 26980 KB | Output is correct |
24 | Correct | 171 ms | 27424 KB | Output is correct |
25 | Correct | 184 ms | 26672 KB | Output is correct |
26 | Correct | 175 ms | 27268 KB | Output is correct |
27 | Correct | 200 ms | 26892 KB | Output is correct |
28 | Correct | 159 ms | 27180 KB | Output is correct |
29 | Correct | 183 ms | 27388 KB | Output is correct |
30 | Correct | 156 ms | 26632 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 972 KB | Output is correct |
2 | Correct | 1 ms | 972 KB | Output is correct |
3 | Correct | 2 ms | 992 KB | Output is correct |
4 | Correct | 1 ms | 972 KB | Output is correct |
5 | Correct | 2 ms | 972 KB | Output is correct |
6 | Correct | 1 ms | 972 KB | Output is correct |
7 | Correct | 1 ms | 716 KB | Output is correct |
8 | Correct | 1 ms | 1032 KB | Output is correct |
9 | Correct | 1 ms | 776 KB | Output is correct |
10 | Correct | 17 ms | 6656 KB | Output is correct |
11 | Correct | 13 ms | 4648 KB | Output is correct |
12 | Correct | 19 ms | 6552 KB | Output is correct |
13 | Correct | 13 ms | 4536 KB | Output is correct |
14 | Correct | 20 ms | 6728 KB | Output is correct |
15 | Correct | 23 ms | 6668 KB | Output is correct |
16 | Correct | 19 ms | 6648 KB | Output is correct |
17 | Correct | 10 ms | 5768 KB | Output is correct |
18 | Correct | 19 ms | 6648 KB | Output is correct |
19 | Correct | 11 ms | 5760 KB | Output is correct |
20 | Correct | 1 ms | 1036 KB | Output is correct |
21 | Correct | 226 ms | 62804 KB | Output is correct |
22 | Correct | 198 ms | 63148 KB | Output is correct |
23 | Correct | 236 ms | 62708 KB | Output is correct |
24 | Correct | 191 ms | 62848 KB | Output is correct |
25 | Correct | 261 ms | 62700 KB | Output is correct |
26 | Correct | 186 ms | 62804 KB | Output is correct |
27 | Correct | 190 ms | 62688 KB | Output is correct |
28 | Correct | 236 ms | 62672 KB | Output is correct |
29 | Correct | 206 ms | 62840 KB | Output is correct |
30 | Correct | 217 ms | 62980 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 972 KB | Output is correct |
2 | Correct | 1 ms | 972 KB | Output is correct |
3 | Correct | 2 ms | 992 KB | Output is correct |
4 | Correct | 1 ms | 972 KB | Output is correct |
5 | Correct | 2 ms | 972 KB | Output is correct |
6 | Correct | 1 ms | 972 KB | Output is correct |
7 | Correct | 1 ms | 716 KB | Output is correct |
8 | Correct | 1 ms | 1032 KB | Output is correct |
9 | Correct | 1 ms | 776 KB | Output is correct |
10 | Correct | 17 ms | 6656 KB | Output is correct |
11 | Correct | 13 ms | 4648 KB | Output is correct |
12 | Correct | 19 ms | 6552 KB | Output is correct |
13 | Correct | 13 ms | 4536 KB | Output is correct |
14 | Correct | 20 ms | 6728 KB | Output is correct |
15 | Correct | 23 ms | 6668 KB | Output is correct |
16 | Correct | 19 ms | 6648 KB | Output is correct |
17 | Correct | 10 ms | 5768 KB | Output is correct |
18 | Correct | 19 ms | 6648 KB | Output is correct |
19 | Correct | 11 ms | 5760 KB | Output is correct |
20 | Correct | 185 ms | 26852 KB | Output is correct |
21 | Correct | 179 ms | 26704 KB | Output is correct |
22 | Correct | 181 ms | 26980 KB | Output is correct |
23 | Correct | 171 ms | 27424 KB | Output is correct |
24 | Correct | 184 ms | 26672 KB | Output is correct |
25 | Correct | 175 ms | 27268 KB | Output is correct |
26 | Correct | 200 ms | 26892 KB | Output is correct |
27 | Correct | 159 ms | 27180 KB | Output is correct |
28 | Correct | 183 ms | 27388 KB | Output is correct |
29 | Correct | 156 ms | 26632 KB | Output is correct |
30 | Correct | 226 ms | 62804 KB | Output is correct |
31 | Correct | 198 ms | 63148 KB | Output is correct |
32 | Correct | 236 ms | 62708 KB | Output is correct |
33 | Correct | 191 ms | 62848 KB | Output is correct |
34 | Correct | 261 ms | 62700 KB | Output is correct |
35 | Correct | 186 ms | 62804 KB | Output is correct |
36 | Correct | 190 ms | 62688 KB | Output is correct |
37 | Correct | 236 ms | 62672 KB | Output is correct |
38 | Correct | 206 ms | 62840 KB | Output is correct |
39 | Correct | 217 ms | 62980 KB | Output is correct |
40 | Correct | 1 ms | 1036 KB | Output is correct |
41 | Correct | 366 ms | 71532 KB | Output is correct |
42 | Correct | 665 ms | 123500 KB | Output is correct |
43 | Correct | 657 ms | 123356 KB | Output is correct |
44 | Correct | 701 ms | 88988 KB | Output is correct |
45 | Correct | 337 ms | 80132 KB | Output is correct |
46 | Correct | 361 ms | 89408 KB | Output is correct |
47 | Correct | 415 ms | 97364 KB | Output is correct |
48 | Correct | 555 ms | 114804 KB | Output is correct |
49 | Correct | 683 ms | 123624 KB | Output is correct |
50 | Correct | 831 ms | 123928 KB | Output is correct |