Submission #898592

# Submission time Handle Problem Language Result Execution time Memory
898592 2024-01-04T22:59:52 Z box Treatment Project (JOI20_treatment) C++17
35 / 100
3000 ms 2652 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
template <class T, class... U> void bug_h(const T& t, const U&... u) { cerr << t; ((cerr << " | " << u), ...); cerr << endl; }
#define bug(...) cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: ", bug_h(__VA_ARGS__)
#else
#define cerr if (0) cerr
#define bug(...)
#endif

#define ar array
#define all(v) std::begin(v), std::end(v)
#define sz(v) int(std::size(v))
typedef long long i64;
typedef vector<int> vi;
typedef pair<int, int> pi;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int N, M;
    cin >> N >> M;
    vi T(M), L(M), R(M), C(M);
    for (int i = 0; i < M; i++) cin >> T[i] >> L[i] >> R[i] >> C[i], L[i]--;
    vector<i64> dist(M, -1);
    typedef pair<i64, int> U;
    priority_queue<U, vector<U>, greater<U>> pq;
    for (int i = 0; i < M; i++) if (L[i] == 0) pq.push({dist[i] = C[i], i});
    while (sz(pq)) {
        auto [d, i] = pq.top(); pq.pop();
        for (int j = 0; j < M; j++) if (dist[j] == -1) {
            if (T[i] <= T[j] && L[j] + T[j] <= R[i] + T[i])
                pq.push({dist[j] = dist[i] + C[j], j});
            if (T[j] < T[i] && R[i] - T[i] >= L[j] - T[j])
                pq.push({dist[j] = dist[i] + C[j], j});
        }
    }
    i64 ans = LLONG_MAX;
    for (int i = 0; i < M; i++) if (~dist[i] && R[i] == N)
        ans = min(ans, dist[i]);
    cout << (ans == LLONG_MAX ? -1 : ans) << '\n';
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3051 ms 2652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 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 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 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 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 44 ms 604 KB Output is correct
21 Correct 36 ms 604 KB Output is correct
22 Correct 58 ms 604 KB Output is correct
23 Correct 42 ms 728 KB Output is correct
24 Correct 25 ms 892 KB Output is correct
25 Correct 39 ms 600 KB Output is correct
26 Correct 35 ms 996 KB Output is correct
27 Correct 45 ms 600 KB Output is correct
28 Correct 28 ms 856 KB Output is correct
29 Correct 39 ms 748 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 548 KB Output is correct
32 Correct 19 ms 908 KB Output is correct
33 Correct 19 ms 880 KB Output is correct
34 Correct 98 ms 736 KB Output is correct
35 Correct 19 ms 860 KB Output is correct
36 Correct 18 ms 860 KB Output is correct
37 Correct 99 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3051 ms 2652 KB Time limit exceeded
2 Halted 0 ms 0 KB -