답안 #583008

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
583008 2022-06-24T16:58:53 Z elkernos 치료 계획 (JOI20_treatment) C++17
35 / 100
3000 ms 7372 KB
#include <bits/stdc++.h>

using namespace std;

struct treatment {
    int t, l, r, c;
    pair<int, int> pocz, kon;
    void read()
    {
        cin >> t >> l >> r >> c;
        r++;
        pocz.first = l + t;
        pocz.second = t - l;
        kon.first = r + t;
        kon.second = t - r;
    }
};

int main()
{
    cin.tie(nullptr)->sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<treatment> they(m + 1);
    for(int i = 1; i <= m; i++) {
        they[i].read();
    }
#define T pair<long long, int>
    priority_queue<T, vector<T>, greater<T>> q;
    const long long ool = 1e18 + 5;
    vector<long long> d(m + 1);
    for(int i = 1; i <= m; i++) {
        if(they[i].l == 1) {
            d[i] = they[i].c;
            q.push({d[i], i});
        }
        else {
            d[i] = ool;
        }
    }
    while(!q.empty()) {
        pair<long long, int> t = q.top();
        q.pop();
        assert(t.first == d[t.second]);
        for(int i = 1; i <= m; i++) {
            if(d[i] > t.first + they[i].c && they[i].pocz.first <= they[t.second].kon.first && they[i].pocz.second >= they[t.second].kon.second) {
                q.emplace(d[i] = t.first + they[i].c, i);
            }
        }
    }
    long long ans = ool;
    for(int i = 1; i <= m; i++) {
        if(they[i].r == n + 1) {
            ans = min(ans, d[i]);
        }
    }
    cout << (ans == ool ? -1 : ans) << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3048 ms 7372 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 276 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 276 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 57 ms 596 KB Output is correct
21 Correct 55 ms 692 KB Output is correct
22 Correct 79 ms 688 KB Output is correct
23 Correct 66 ms 608 KB Output is correct
24 Correct 44 ms 836 KB Output is correct
25 Correct 57 ms 724 KB Output is correct
26 Correct 41 ms 696 KB Output is correct
27 Correct 40 ms 724 KB Output is correct
28 Correct 47 ms 852 KB Output is correct
29 Correct 48 ms 724 KB Output is correct
30 Correct 4 ms 696 KB Output is correct
31 Correct 3 ms 724 KB Output is correct
32 Correct 36 ms 920 KB Output is correct
33 Correct 36 ms 916 KB Output is correct
34 Correct 62 ms 716 KB Output is correct
35 Correct 34 ms 852 KB Output is correct
36 Correct 37 ms 880 KB Output is correct
37 Correct 63 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3048 ms 7372 KB Time limit exceeded
2 Halted 0 ms 0 KB -