# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1103654 |
2024-10-21T13:06:51 Z |
ortsac |
Toll (BOI17_toll) |
C++17 |
|
1590 ms |
7860 KB |
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define fm first
#define t second
const int MAXN = 5e4 + 10;
const int INF = 0x3f3f3f3f;
vector<pii> rec[MAXN];
int ans[MAXN];
void calc(int a, int b) {
for (int i = max(a - 10, 0); i <= (b + 10); i++) ans[i] = INF;
ans[a] = 0;
for (int i = a + 1; i <= b; i++) {
for (auto u : rec[i]) ans[i] = min(ans[i], ans[u.fm] + u.t);
}
}
int32_t main() {
int k, n, m, o;
cin >> k >> n >> m >> o;
for (int i = 0; i < m; i++) {
int a, b, toll;
cin >> a >> b >> toll;
rec[b].push_back({a, toll});
}
for (int i = 0; i < o; i++) {
int a, b;
cin >> a >> b;
calc(a, b);
cout << ((ans[b] == INF) ? -1 : ans[b]) << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
558 ms |
3400 KB |
Output is correct |
2 |
Correct |
2 ms |
1616 KB |
Output is correct |
3 |
Correct |
1 ms |
1616 KB |
Output is correct |
4 |
Correct |
2 ms |
1784 KB |
Output is correct |
5 |
Correct |
4 ms |
1616 KB |
Output is correct |
6 |
Correct |
5 ms |
1616 KB |
Output is correct |
7 |
Correct |
4 ms |
1616 KB |
Output is correct |
8 |
Correct |
537 ms |
3360 KB |
Output is correct |
9 |
Correct |
534 ms |
3292 KB |
Output is correct |
10 |
Correct |
157 ms |
1808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1121 ms |
3388 KB |
Output is correct |
2 |
Correct |
2 ms |
1616 KB |
Output is correct |
3 |
Correct |
2 ms |
1616 KB |
Output is correct |
4 |
Correct |
2 ms |
1616 KB |
Output is correct |
5 |
Correct |
1 ms |
1616 KB |
Output is correct |
6 |
Correct |
1 ms |
1616 KB |
Output is correct |
7 |
Correct |
27 ms |
1664 KB |
Output is correct |
8 |
Correct |
37 ms |
1788 KB |
Output is correct |
9 |
Correct |
803 ms |
3384 KB |
Output is correct |
10 |
Correct |
1590 ms |
4252 KB |
Output is correct |
11 |
Correct |
1107 ms |
3400 KB |
Output is correct |
12 |
Correct |
1331 ms |
3144 KB |
Output is correct |
13 |
Correct |
480 ms |
4424 KB |
Output is correct |
14 |
Correct |
326 ms |
3144 KB |
Output is correct |
15 |
Correct |
326 ms |
2936 KB |
Output is correct |
16 |
Correct |
330 ms |
3040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1616 KB |
Output is correct |
2 |
Correct |
1 ms |
1616 KB |
Output is correct |
3 |
Correct |
2 ms |
1616 KB |
Output is correct |
4 |
Correct |
2 ms |
1616 KB |
Output is correct |
5 |
Correct |
1 ms |
1616 KB |
Output is correct |
6 |
Correct |
2 ms |
1620 KB |
Output is correct |
7 |
Correct |
3 ms |
1672 KB |
Output is correct |
8 |
Correct |
5 ms |
1784 KB |
Output is correct |
9 |
Correct |
4 ms |
1620 KB |
Output is correct |
10 |
Correct |
35 ms |
4084 KB |
Output is correct |
11 |
Correct |
61 ms |
4684 KB |
Output is correct |
12 |
Correct |
89 ms |
6220 KB |
Output is correct |
13 |
Correct |
91 ms |
6736 KB |
Output is correct |
14 |
Correct |
74 ms |
5456 KB |
Output is correct |
15 |
Correct |
48 ms |
4172 KB |
Output is correct |
16 |
Correct |
51 ms |
4172 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1616 KB |
Output is correct |
2 |
Correct |
1 ms |
1616 KB |
Output is correct |
3 |
Correct |
2 ms |
1616 KB |
Output is correct |
4 |
Correct |
2 ms |
1616 KB |
Output is correct |
5 |
Correct |
1 ms |
1616 KB |
Output is correct |
6 |
Correct |
2 ms |
1620 KB |
Output is correct |
7 |
Correct |
3 ms |
1672 KB |
Output is correct |
8 |
Correct |
5 ms |
1784 KB |
Output is correct |
9 |
Correct |
4 ms |
1620 KB |
Output is correct |
10 |
Correct |
35 ms |
4084 KB |
Output is correct |
11 |
Correct |
61 ms |
4684 KB |
Output is correct |
12 |
Correct |
89 ms |
6220 KB |
Output is correct |
13 |
Correct |
91 ms |
6736 KB |
Output is correct |
14 |
Correct |
74 ms |
5456 KB |
Output is correct |
15 |
Correct |
48 ms |
4172 KB |
Output is correct |
16 |
Correct |
51 ms |
4172 KB |
Output is correct |
17 |
Correct |
280 ms |
4884 KB |
Output is correct |
18 |
Correct |
1 ms |
1620 KB |
Output is correct |
19 |
Correct |
2 ms |
1620 KB |
Output is correct |
20 |
Correct |
1 ms |
1620 KB |
Output is correct |
21 |
Correct |
1 ms |
1364 KB |
Output is correct |
22 |
Correct |
2 ms |
1620 KB |
Output is correct |
23 |
Correct |
9 ms |
1620 KB |
Output is correct |
24 |
Correct |
11 ms |
1620 KB |
Output is correct |
25 |
Correct |
13 ms |
1620 KB |
Output is correct |
26 |
Correct |
12 ms |
1620 KB |
Output is correct |
27 |
Correct |
193 ms |
4212 KB |
Output is correct |
28 |
Correct |
374 ms |
6476 KB |
Output is correct |
29 |
Correct |
402 ms |
6732 KB |
Output is correct |
30 |
Correct |
375 ms |
5708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
558 ms |
3400 KB |
Output is correct |
2 |
Correct |
2 ms |
1616 KB |
Output is correct |
3 |
Correct |
1 ms |
1616 KB |
Output is correct |
4 |
Correct |
2 ms |
1784 KB |
Output is correct |
5 |
Correct |
4 ms |
1616 KB |
Output is correct |
6 |
Correct |
5 ms |
1616 KB |
Output is correct |
7 |
Correct |
4 ms |
1616 KB |
Output is correct |
8 |
Correct |
537 ms |
3360 KB |
Output is correct |
9 |
Correct |
534 ms |
3292 KB |
Output is correct |
10 |
Correct |
157 ms |
1808 KB |
Output is correct |
11 |
Correct |
1121 ms |
3388 KB |
Output is correct |
12 |
Correct |
2 ms |
1616 KB |
Output is correct |
13 |
Correct |
2 ms |
1616 KB |
Output is correct |
14 |
Correct |
2 ms |
1616 KB |
Output is correct |
15 |
Correct |
1 ms |
1616 KB |
Output is correct |
16 |
Correct |
1 ms |
1616 KB |
Output is correct |
17 |
Correct |
27 ms |
1664 KB |
Output is correct |
18 |
Correct |
37 ms |
1788 KB |
Output is correct |
19 |
Correct |
803 ms |
3384 KB |
Output is correct |
20 |
Correct |
1590 ms |
4252 KB |
Output is correct |
21 |
Correct |
1107 ms |
3400 KB |
Output is correct |
22 |
Correct |
1331 ms |
3144 KB |
Output is correct |
23 |
Correct |
480 ms |
4424 KB |
Output is correct |
24 |
Correct |
326 ms |
3144 KB |
Output is correct |
25 |
Correct |
326 ms |
2936 KB |
Output is correct |
26 |
Correct |
330 ms |
3040 KB |
Output is correct |
27 |
Correct |
1 ms |
1616 KB |
Output is correct |
28 |
Correct |
1 ms |
1616 KB |
Output is correct |
29 |
Correct |
2 ms |
1616 KB |
Output is correct |
30 |
Correct |
2 ms |
1616 KB |
Output is correct |
31 |
Correct |
1 ms |
1616 KB |
Output is correct |
32 |
Correct |
2 ms |
1620 KB |
Output is correct |
33 |
Correct |
3 ms |
1672 KB |
Output is correct |
34 |
Correct |
5 ms |
1784 KB |
Output is correct |
35 |
Correct |
4 ms |
1620 KB |
Output is correct |
36 |
Correct |
35 ms |
4084 KB |
Output is correct |
37 |
Correct |
61 ms |
4684 KB |
Output is correct |
38 |
Correct |
89 ms |
6220 KB |
Output is correct |
39 |
Correct |
91 ms |
6736 KB |
Output is correct |
40 |
Correct |
74 ms |
5456 KB |
Output is correct |
41 |
Correct |
48 ms |
4172 KB |
Output is correct |
42 |
Correct |
51 ms |
4172 KB |
Output is correct |
43 |
Correct |
280 ms |
4884 KB |
Output is correct |
44 |
Correct |
1 ms |
1620 KB |
Output is correct |
45 |
Correct |
2 ms |
1620 KB |
Output is correct |
46 |
Correct |
1 ms |
1620 KB |
Output is correct |
47 |
Correct |
1 ms |
1364 KB |
Output is correct |
48 |
Correct |
2 ms |
1620 KB |
Output is correct |
49 |
Correct |
9 ms |
1620 KB |
Output is correct |
50 |
Correct |
11 ms |
1620 KB |
Output is correct |
51 |
Correct |
13 ms |
1620 KB |
Output is correct |
52 |
Correct |
12 ms |
1620 KB |
Output is correct |
53 |
Correct |
193 ms |
4212 KB |
Output is correct |
54 |
Correct |
374 ms |
6476 KB |
Output is correct |
55 |
Correct |
402 ms |
6732 KB |
Output is correct |
56 |
Correct |
375 ms |
5708 KB |
Output is correct |
57 |
Correct |
1367 ms |
7860 KB |
Output is correct |
58 |
Correct |
539 ms |
4180 KB |
Output is correct |
59 |
Correct |
803 ms |
5148 KB |
Output is correct |