# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
878450 |
2023-11-24T11:30:02 Z |
nima_aryan |
Toll (BOI17_toll) |
C++14 |
|
2132 ms |
7948 KB |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#ifdef LOCAL
#include "algo/debug.h"
#endif
using i64 = long long;
constexpr int inf = 1E9;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int K, N, M, O;
cin >> K >> N >> M >> O;
vector<vector<pair<int, int>>> g(N);
for (int i = 0; i < M; ++i) {
int a, b;
cin >> a >> b;
int t;
cin >> t;
g[b].emplace_back(a, t);
}
while (O--) {
int a, b;
cin >> a >> b;
if (a > b) {
cout << -1 << "\n";
continue;
}
vector<int> d(b - a + 1, inf);
d[0] = 0;
for (int u = a + 1; u <= b; ++u) {
for (auto& [v, t] : g[u]) {
if (v - a >= 0) {
d[u - a] = min(d[u - a], d[v - a] + t);
}
}
}
cout << (d.back() < inf ? d.back() : -1) << "\n";
}
return 0;
}
Compilation message
toll.cpp: In function 'int main()':
toll.cpp:44:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
44 | for (auto& [v, t] : g[u]) {
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
767 ms |
3640 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
472 KB |
Output is correct |
8 |
Correct |
781 ms |
4336 KB |
Output is correct |
9 |
Correct |
761 ms |
4284 KB |
Output is correct |
10 |
Correct |
238 ms |
1884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1470 ms |
3656 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
20 ms |
548 KB |
Output is correct |
8 |
Correct |
20 ms |
604 KB |
Output is correct |
9 |
Correct |
1149 ms |
3632 KB |
Output is correct |
10 |
Correct |
2132 ms |
4592 KB |
Output is correct |
11 |
Correct |
1572 ms |
3480 KB |
Output is correct |
12 |
Correct |
2079 ms |
3324 KB |
Output is correct |
13 |
Correct |
541 ms |
4256 KB |
Output is correct |
14 |
Correct |
383 ms |
2980 KB |
Output is correct |
15 |
Correct |
438 ms |
2600 KB |
Output is correct |
16 |
Correct |
450 ms |
2816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
456 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
21 ms |
4188 KB |
Output is correct |
11 |
Correct |
40 ms |
4824 KB |
Output is correct |
12 |
Correct |
43 ms |
6408 KB |
Output is correct |
13 |
Correct |
47 ms |
6992 KB |
Output is correct |
14 |
Correct |
42 ms |
5712 KB |
Output is correct |
15 |
Correct |
27 ms |
3668 KB |
Output is correct |
16 |
Correct |
26 ms |
3668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
456 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
21 ms |
4188 KB |
Output is correct |
11 |
Correct |
40 ms |
4824 KB |
Output is correct |
12 |
Correct |
43 ms |
6408 KB |
Output is correct |
13 |
Correct |
47 ms |
6992 KB |
Output is correct |
14 |
Correct |
42 ms |
5712 KB |
Output is correct |
15 |
Correct |
27 ms |
3668 KB |
Output is correct |
16 |
Correct |
26 ms |
3668 KB |
Output is correct |
17 |
Correct |
333 ms |
5196 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
600 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
5 ms |
348 KB |
Output is correct |
24 |
Correct |
5 ms |
600 KB |
Output is correct |
25 |
Correct |
8 ms |
600 KB |
Output is correct |
26 |
Correct |
8 ms |
604 KB |
Output is correct |
27 |
Correct |
231 ms |
4264 KB |
Output is correct |
28 |
Correct |
444 ms |
6512 KB |
Output is correct |
29 |
Correct |
439 ms |
6992 KB |
Output is correct |
30 |
Correct |
492 ms |
5748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
767 ms |
3640 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
472 KB |
Output is correct |
8 |
Correct |
781 ms |
4336 KB |
Output is correct |
9 |
Correct |
761 ms |
4284 KB |
Output is correct |
10 |
Correct |
238 ms |
1884 KB |
Output is correct |
11 |
Correct |
1470 ms |
3656 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
20 ms |
548 KB |
Output is correct |
18 |
Correct |
20 ms |
604 KB |
Output is correct |
19 |
Correct |
1149 ms |
3632 KB |
Output is correct |
20 |
Correct |
2132 ms |
4592 KB |
Output is correct |
21 |
Correct |
1572 ms |
3480 KB |
Output is correct |
22 |
Correct |
2079 ms |
3324 KB |
Output is correct |
23 |
Correct |
541 ms |
4256 KB |
Output is correct |
24 |
Correct |
383 ms |
2980 KB |
Output is correct |
25 |
Correct |
438 ms |
2600 KB |
Output is correct |
26 |
Correct |
450 ms |
2816 KB |
Output is correct |
27 |
Correct |
1 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
456 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
600 KB |
Output is correct |
35 |
Correct |
1 ms |
604 KB |
Output is correct |
36 |
Correct |
21 ms |
4188 KB |
Output is correct |
37 |
Correct |
40 ms |
4824 KB |
Output is correct |
38 |
Correct |
43 ms |
6408 KB |
Output is correct |
39 |
Correct |
47 ms |
6992 KB |
Output is correct |
40 |
Correct |
42 ms |
5712 KB |
Output is correct |
41 |
Correct |
27 ms |
3668 KB |
Output is correct |
42 |
Correct |
26 ms |
3668 KB |
Output is correct |
43 |
Correct |
333 ms |
5196 KB |
Output is correct |
44 |
Correct |
0 ms |
344 KB |
Output is correct |
45 |
Correct |
1 ms |
348 KB |
Output is correct |
46 |
Correct |
0 ms |
348 KB |
Output is correct |
47 |
Correct |
0 ms |
600 KB |
Output is correct |
48 |
Correct |
1 ms |
348 KB |
Output is correct |
49 |
Correct |
5 ms |
348 KB |
Output is correct |
50 |
Correct |
5 ms |
600 KB |
Output is correct |
51 |
Correct |
8 ms |
600 KB |
Output is correct |
52 |
Correct |
8 ms |
604 KB |
Output is correct |
53 |
Correct |
231 ms |
4264 KB |
Output is correct |
54 |
Correct |
444 ms |
6512 KB |
Output is correct |
55 |
Correct |
439 ms |
6992 KB |
Output is correct |
56 |
Correct |
492 ms |
5748 KB |
Output is correct |
57 |
Correct |
1650 ms |
7948 KB |
Output is correct |
58 |
Correct |
773 ms |
4512 KB |
Output is correct |
59 |
Correct |
1082 ms |
5340 KB |
Output is correct |