Submission #1103653

# Submission time Handle Problem Language Result Execution time Memory
1103653 2024-10-21T13:01:38 Z ortsac Toll (BOI17_toll) C++17
17 / 100
1879 ms 6732 KB
#include <bits/stdc++.h>

using namespace std;

#define pii pair<int, int>
#define fm first
#define t second

const int MAXN = 5e4 + 10;

vector<pii> rec[MAXN];
int ans[MAXN];

void calc(int a, int b) {
    for (int i = max(a - 5, 0); i <= b; i++) ans[i] = -1;
    ans[a] = 0;
    for (int i = a + 1; i <= b; i++) {
        for (auto u : rec[i]) {
            if (ans[u.fm] != -1) {
                if (ans[i] == -1) ans[i] = (ans[u.fm] + u.t);
                else 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] << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 468 ms 4304 KB Output is correct
2 Correct 2 ms 1620 KB Output is correct
3 Correct 1 ms 1620 KB Output is correct
4 Correct 1 ms 1616 KB Output is correct
5 Correct 4 ms 1620 KB Output is correct
6 Correct 4 ms 1620 KB Output is correct
7 Correct 4 ms 1784 KB Output is correct
8 Correct 389 ms 4180 KB Output is correct
9 Correct 379 ms 4180 KB Output is correct
10 Correct 150 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1142 ms 4856 KB Output is correct
2 Correct 2 ms 1620 KB Output is correct
3 Correct 2 ms 1620 KB Output is correct
4 Correct 1 ms 1620 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1620 KB Output is correct
7 Correct 25 ms 1756 KB Output is correct
8 Correct 35 ms 1620 KB Output is correct
9 Correct 540 ms 4172 KB Output is correct
10 Correct 1879 ms 6540 KB Output is correct
11 Correct 1346 ms 4940 KB Output is correct
12 Correct 1412 ms 4572 KB Output is correct
13 Correct 619 ms 6732 KB Output is correct
14 Correct 370 ms 4684 KB Output is correct
15 Correct 427 ms 4172 KB Output is correct
16 Correct 424 ms 4172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1620 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1620 KB Output is correct
5 Incorrect 1 ms 1620 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1620 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1620 KB Output is correct
5 Incorrect 1 ms 1620 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 468 ms 4304 KB Output is correct
2 Correct 2 ms 1620 KB Output is correct
3 Correct 1 ms 1620 KB Output is correct
4 Correct 1 ms 1616 KB Output is correct
5 Correct 4 ms 1620 KB Output is correct
6 Correct 4 ms 1620 KB Output is correct
7 Correct 4 ms 1784 KB Output is correct
8 Correct 389 ms 4180 KB Output is correct
9 Correct 379 ms 4180 KB Output is correct
10 Correct 150 ms 1868 KB Output is correct
11 Correct 1142 ms 4856 KB Output is correct
12 Correct 2 ms 1620 KB Output is correct
13 Correct 2 ms 1620 KB Output is correct
14 Correct 1 ms 1620 KB Output is correct
15 Correct 1 ms 1620 KB Output is correct
16 Correct 1 ms 1620 KB Output is correct
17 Correct 25 ms 1756 KB Output is correct
18 Correct 35 ms 1620 KB Output is correct
19 Correct 540 ms 4172 KB Output is correct
20 Correct 1879 ms 6540 KB Output is correct
21 Correct 1346 ms 4940 KB Output is correct
22 Correct 1412 ms 4572 KB Output is correct
23 Correct 619 ms 6732 KB Output is correct
24 Correct 370 ms 4684 KB Output is correct
25 Correct 427 ms 4172 KB Output is correct
26 Correct 424 ms 4172 KB Output is correct
27 Correct 2 ms 1620 KB Output is correct
28 Correct 1 ms 1748 KB Output is correct
29 Correct 1 ms 1364 KB Output is correct
30 Correct 1 ms 1620 KB Output is correct
31 Incorrect 1 ms 1620 KB Output isn't correct
32 Halted 0 ms 0 KB -