# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
241894 |
2020-06-26T09:17:46 Z |
jjwdi0 |
None (KOI17_cook) |
C++11 |
|
807 ms |
66424 KB |
#include <bits/stdc++.h>
using namespace std;
using pr = pair<int, int>;
int N, M, S, E, T, D[3005][3005];
int sum[3005][3005], imp[3005], mn[3005][3];
deque<pr> dq[3005];
priority_queue<pr, vector<pr>, greater<pr>> pq;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> N >> M >> S >> E >> T;
for(int i=1; i<=N; i++) for(int j=1; j<=M; j++) {
cin >> sum[i][j];
sum[i][j] += sum[i][j-1];
}
for(int i=1; i<=N; i++) cin >> imp[i];
for(int i=1; i<=N; i++) D[i][0] = -T;
for(int i=1; i<=N; i++) for(int j=1; j<=M; j++) D[i][j] = 1e9;
for(int j=S; j<=M+S-1; j++) {
while(!pq.empty()) pq.pop();
for(int i=1; i<=N; i++) pq.push(pr(D[i][j-S], i));
int x = pq.top().second; pq.pop();
int y = pq.top().second; pq.pop();
int z = pq.top().second; pq.pop();
for(int i=1; i<=N; i++) {
int cur = 0;
if(x != imp[i] && x != i) cur = D[x][j-S];
else if(y != imp[i] && y != i) cur = D[y][j-S];
else cur = D[z][j-S];
while(!dq[i].empty() && dq[i].front().second < (j <= M ? j - E : -100000)) dq[i].pop_front();
while(!dq[i].empty() && dq[i].back().first >= cur - sum[i][j-S]) dq[i].pop_back();
dq[i].push_back(pr(cur - sum[i][j-S], j - S));
if(j <= M) D[i][j] = min(D[i][j], dq[i].front().first + sum[i][j] + T);
}
}
int ans = 1e9;
for(int i=1; i<=N; i++) {
// cout << i << ": " << (dq[i].front().first + sum[i][M] + T) << "\n";
ans = min(ans, dq[i].front().first + sum[i][M] + T);
}
assert(0 <= ans && ans < 1e9);
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2816 KB |
Output is correct |
2 |
Correct |
7 ms |
2816 KB |
Output is correct |
3 |
Correct |
6 ms |
2816 KB |
Output is correct |
4 |
Correct |
6 ms |
2688 KB |
Output is correct |
5 |
Correct |
6 ms |
2816 KB |
Output is correct |
6 |
Correct |
7 ms |
2688 KB |
Output is correct |
7 |
Correct |
6 ms |
2816 KB |
Output is correct |
8 |
Correct |
6 ms |
2816 KB |
Output is correct |
9 |
Correct |
6 ms |
2816 KB |
Output is correct |
10 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2816 KB |
Output is correct |
2 |
Correct |
7 ms |
2816 KB |
Output is correct |
3 |
Correct |
6 ms |
2816 KB |
Output is correct |
4 |
Correct |
6 ms |
2688 KB |
Output is correct |
5 |
Correct |
6 ms |
2816 KB |
Output is correct |
6 |
Correct |
7 ms |
2688 KB |
Output is correct |
7 |
Correct |
6 ms |
2816 KB |
Output is correct |
8 |
Correct |
6 ms |
2816 KB |
Output is correct |
9 |
Correct |
6 ms |
2816 KB |
Output is correct |
10 |
Correct |
26 ms |
6016 KB |
Output is correct |
11 |
Correct |
21 ms |
5632 KB |
Output is correct |
12 |
Correct |
27 ms |
6144 KB |
Output is correct |
13 |
Correct |
20 ms |
5632 KB |
Output is correct |
14 |
Correct |
24 ms |
6016 KB |
Output is correct |
15 |
Correct |
24 ms |
6016 KB |
Output is correct |
16 |
Correct |
27 ms |
6016 KB |
Output is correct |
17 |
Correct |
17 ms |
4736 KB |
Output is correct |
18 |
Correct |
23 ms |
6016 KB |
Output is correct |
19 |
Correct |
18 ms |
4736 KB |
Output is correct |
20 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2816 KB |
Output is correct |
2 |
Correct |
7 ms |
2816 KB |
Output is correct |
3 |
Correct |
6 ms |
2816 KB |
Output is correct |
4 |
Correct |
6 ms |
2688 KB |
Output is correct |
5 |
Correct |
6 ms |
2816 KB |
Output is correct |
6 |
Correct |
7 ms |
2688 KB |
Output is correct |
7 |
Correct |
6 ms |
2816 KB |
Output is correct |
8 |
Correct |
6 ms |
2816 KB |
Output is correct |
9 |
Correct |
6 ms |
2816 KB |
Output is correct |
10 |
Correct |
26 ms |
6016 KB |
Output is correct |
11 |
Correct |
21 ms |
5632 KB |
Output is correct |
12 |
Correct |
27 ms |
6144 KB |
Output is correct |
13 |
Correct |
20 ms |
5632 KB |
Output is correct |
14 |
Correct |
24 ms |
6016 KB |
Output is correct |
15 |
Correct |
24 ms |
6016 KB |
Output is correct |
16 |
Correct |
27 ms |
6016 KB |
Output is correct |
17 |
Correct |
17 ms |
4736 KB |
Output is correct |
18 |
Correct |
23 ms |
6016 KB |
Output is correct |
19 |
Correct |
18 ms |
4736 KB |
Output is correct |
20 |
Correct |
214 ms |
38520 KB |
Output is correct |
21 |
Correct |
248 ms |
38524 KB |
Output is correct |
22 |
Correct |
262 ms |
38520 KB |
Output is correct |
23 |
Correct |
222 ms |
38524 KB |
Output is correct |
24 |
Correct |
198 ms |
38520 KB |
Output is correct |
25 |
Correct |
270 ms |
38520 KB |
Output is correct |
26 |
Correct |
250 ms |
38648 KB |
Output is correct |
27 |
Correct |
209 ms |
38544 KB |
Output is correct |
28 |
Correct |
248 ms |
38648 KB |
Output is correct |
29 |
Correct |
199 ms |
38520 KB |
Output is correct |
30 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2816 KB |
Output is correct |
2 |
Correct |
7 ms |
2816 KB |
Output is correct |
3 |
Correct |
6 ms |
2816 KB |
Output is correct |
4 |
Correct |
6 ms |
2688 KB |
Output is correct |
5 |
Correct |
6 ms |
2816 KB |
Output is correct |
6 |
Correct |
7 ms |
2688 KB |
Output is correct |
7 |
Correct |
6 ms |
2816 KB |
Output is correct |
8 |
Correct |
6 ms |
2816 KB |
Output is correct |
9 |
Correct |
6 ms |
2816 KB |
Output is correct |
10 |
Correct |
26 ms |
6016 KB |
Output is correct |
11 |
Correct |
21 ms |
5632 KB |
Output is correct |
12 |
Correct |
27 ms |
6144 KB |
Output is correct |
13 |
Correct |
20 ms |
5632 KB |
Output is correct |
14 |
Correct |
24 ms |
6016 KB |
Output is correct |
15 |
Correct |
24 ms |
6016 KB |
Output is correct |
16 |
Correct |
27 ms |
6016 KB |
Output is correct |
17 |
Correct |
17 ms |
4736 KB |
Output is correct |
18 |
Correct |
23 ms |
6016 KB |
Output is correct |
19 |
Correct |
18 ms |
4736 KB |
Output is correct |
20 |
Correct |
215 ms |
14328 KB |
Output is correct |
21 |
Correct |
192 ms |
14456 KB |
Output is correct |
22 |
Correct |
202 ms |
14328 KB |
Output is correct |
23 |
Correct |
180 ms |
14332 KB |
Output is correct |
24 |
Correct |
205 ms |
14328 KB |
Output is correct |
25 |
Correct |
169 ms |
14328 KB |
Output is correct |
26 |
Correct |
201 ms |
14456 KB |
Output is correct |
27 |
Correct |
213 ms |
14328 KB |
Output is correct |
28 |
Correct |
190 ms |
14456 KB |
Output is correct |
29 |
Correct |
176 ms |
14328 KB |
Output is correct |
30 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2816 KB |
Output is correct |
2 |
Correct |
7 ms |
2816 KB |
Output is correct |
3 |
Correct |
6 ms |
2816 KB |
Output is correct |
4 |
Correct |
6 ms |
2688 KB |
Output is correct |
5 |
Correct |
6 ms |
2816 KB |
Output is correct |
6 |
Correct |
7 ms |
2688 KB |
Output is correct |
7 |
Correct |
6 ms |
2816 KB |
Output is correct |
8 |
Correct |
6 ms |
2816 KB |
Output is correct |
9 |
Correct |
6 ms |
2816 KB |
Output is correct |
10 |
Correct |
26 ms |
6016 KB |
Output is correct |
11 |
Correct |
21 ms |
5632 KB |
Output is correct |
12 |
Correct |
27 ms |
6144 KB |
Output is correct |
13 |
Correct |
20 ms |
5632 KB |
Output is correct |
14 |
Correct |
24 ms |
6016 KB |
Output is correct |
15 |
Correct |
24 ms |
6016 KB |
Output is correct |
16 |
Correct |
27 ms |
6016 KB |
Output is correct |
17 |
Correct |
17 ms |
4736 KB |
Output is correct |
18 |
Correct |
23 ms |
6016 KB |
Output is correct |
19 |
Correct |
18 ms |
4736 KB |
Output is correct |
20 |
Correct |
214 ms |
38520 KB |
Output is correct |
21 |
Correct |
248 ms |
38524 KB |
Output is correct |
22 |
Correct |
262 ms |
38520 KB |
Output is correct |
23 |
Correct |
222 ms |
38524 KB |
Output is correct |
24 |
Correct |
198 ms |
38520 KB |
Output is correct |
25 |
Correct |
270 ms |
38520 KB |
Output is correct |
26 |
Correct |
250 ms |
38648 KB |
Output is correct |
27 |
Correct |
209 ms |
38544 KB |
Output is correct |
28 |
Correct |
248 ms |
38648 KB |
Output is correct |
29 |
Correct |
199 ms |
38520 KB |
Output is correct |
30 |
Correct |
215 ms |
14328 KB |
Output is correct |
31 |
Correct |
192 ms |
14456 KB |
Output is correct |
32 |
Correct |
202 ms |
14328 KB |
Output is correct |
33 |
Correct |
180 ms |
14332 KB |
Output is correct |
34 |
Correct |
205 ms |
14328 KB |
Output is correct |
35 |
Correct |
169 ms |
14328 KB |
Output is correct |
36 |
Correct |
201 ms |
14456 KB |
Output is correct |
37 |
Correct |
213 ms |
14328 KB |
Output is correct |
38 |
Correct |
190 ms |
14456 KB |
Output is correct |
39 |
Correct |
176 ms |
14328 KB |
Output is correct |
40 |
Correct |
280 ms |
18424 KB |
Output is correct |
41 |
Correct |
807 ms |
42488 KB |
Output is correct |
42 |
Correct |
739 ms |
42488 KB |
Output is correct |
43 |
Correct |
769 ms |
66424 KB |
Output is correct |
44 |
Correct |
291 ms |
22264 KB |
Output is correct |
45 |
Correct |
411 ms |
26464 KB |
Output is correct |
46 |
Correct |
407 ms |
30648 KB |
Output is correct |
47 |
Correct |
565 ms |
38264 KB |
Output is correct |
48 |
Correct |
777 ms |
42360 KB |
Output is correct |
49 |
Correct |
782 ms |
42492 KB |
Output is correct |
50 |
Correct |
6 ms |
2688 KB |
Output is correct |