Submission #952680

# Submission time Handle Problem Language Result Execution time Memory
952680 2024-03-24T14:20:39 Z offlineDeletionTrickFan Fuel Station (NOI20_fuelstation) C++17
100 / 100
137 ms 27076 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 3e5 + 5;
struct station {
    int a, b, x;
    bool operator<(const station& other) const {
        return x < other.x;
    }
} v[MAXN];
signed main () {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, d;
    cin >> n >> d;
    ++n;
    for (int i = 1; i < n; ++i) cin >> v[i].x >> v[i].a >> v[i].b;
    v[n].a = v[n].b = 0;
    v[n].x = d;
    sort(v + 1, v + n + 1);
    int ans = 0, curf = 0;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq;
    for (int i = 1; i <= n; ++i) {
        if (curf < v[i].x) {
            ans += v[i].x - curf;
            curf = v[i].x;
        }
        while (!pq.empty() && pq.top().first < ans) {
            curf -= pq.top().second; pq.pop();
            if (curf < v[i].x) {
                ans += v[i].x - curf;
                curf = v[i].x;
            }
        }
        if (ans <= v[i].b) {
            curf += v[i].a;
            pq.push({v[i].b, v[i].a});
        }
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 504 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 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 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 98 ms 17076 KB Output is correct
2 Correct 106 ms 25676 KB Output is correct
3 Correct 93 ms 24924 KB Output is correct
4 Correct 89 ms 24660 KB Output is correct
5 Correct 92 ms 25512 KB Output is correct
6 Correct 117 ms 25176 KB Output is correct
7 Correct 90 ms 24892 KB Output is correct
8 Correct 89 ms 25028 KB Output is correct
9 Correct 95 ms 27076 KB Output is correct
10 Correct 86 ms 24872 KB Output is correct
11 Correct 91 ms 24532 KB Output is correct
12 Correct 89 ms 25284 KB Output is correct
13 Correct 93 ms 25572 KB Output is correct
14 Correct 96 ms 24260 KB Output is correct
15 Correct 89 ms 24924 KB Output is correct
16 Correct 97 ms 25800 KB Output is correct
17 Correct 94 ms 24924 KB Output is correct
18 Correct 96 ms 25796 KB Output is correct
19 Correct 88 ms 25540 KB Output is correct
20 Correct 97 ms 24260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 3 ms 3032 KB Output is correct
3 Correct 4 ms 3164 KB Output is correct
4 Correct 3 ms 3164 KB Output is correct
5 Correct 4 ms 3160 KB Output is correct
6 Correct 3 ms 3160 KB Output is correct
7 Correct 4 ms 3140 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 2648 KB Output is correct
15 Correct 3 ms 2652 KB Output is correct
16 Correct 3 ms 2644 KB Output is correct
17 Correct 3 ms 2652 KB Output is correct
18 Correct 3 ms 2652 KB Output is correct
19 Correct 3 ms 3168 KB Output is correct
20 Correct 3 ms 3164 KB Output is correct
21 Correct 3 ms 3164 KB Output is correct
22 Correct 3 ms 3164 KB Output is correct
23 Correct 3 ms 3164 KB Output is correct
24 Correct 3 ms 3420 KB Output is correct
25 Correct 3 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 3 ms 3032 KB Output is correct
3 Correct 4 ms 3164 KB Output is correct
4 Correct 3 ms 3164 KB Output is correct
5 Correct 4 ms 3160 KB Output is correct
6 Correct 3 ms 3160 KB Output is correct
7 Correct 4 ms 3140 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 2648 KB Output is correct
15 Correct 3 ms 2652 KB Output is correct
16 Correct 3 ms 2644 KB Output is correct
17 Correct 3 ms 2652 KB Output is correct
18 Correct 3 ms 2652 KB Output is correct
19 Correct 3 ms 3168 KB Output is correct
20 Correct 3 ms 3164 KB Output is correct
21 Correct 3 ms 3164 KB Output is correct
22 Correct 3 ms 3164 KB Output is correct
23 Correct 3 ms 3164 KB Output is correct
24 Correct 3 ms 3420 KB Output is correct
25 Correct 3 ms 3164 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 70 ms 20800 KB Output is correct
28 Correct 71 ms 19836 KB Output is correct
29 Correct 71 ms 20936 KB Output is correct
30 Correct 79 ms 21636 KB Output is correct
31 Correct 74 ms 21704 KB Output is correct
32 Correct 75 ms 21188 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 61 ms 11636 KB Output is correct
40 Correct 61 ms 11624 KB Output is correct
41 Correct 63 ms 11604 KB Output is correct
42 Correct 63 ms 11600 KB Output is correct
43 Correct 79 ms 11664 KB Output is correct
44 Correct 68 ms 13536 KB Output is correct
45 Correct 80 ms 11092 KB Output is correct
46 Correct 70 ms 20308 KB Output is correct
47 Correct 76 ms 22232 KB Output is correct
48 Correct 82 ms 23312 KB Output is correct
49 Correct 74 ms 19396 KB Output is correct
50 Correct 68 ms 20936 KB Output is correct
51 Correct 71 ms 21708 KB Output is correct
52 Correct 65 ms 20680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 504 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 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 344 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 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 464 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 464 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 504 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 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 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 3 ms 3032 KB Output is correct
18 Correct 4 ms 3164 KB Output is correct
19 Correct 3 ms 3164 KB Output is correct
20 Correct 4 ms 3160 KB Output is correct
21 Correct 3 ms 3160 KB Output is correct
22 Correct 4 ms 3140 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 3 ms 2648 KB Output is correct
30 Correct 3 ms 2652 KB Output is correct
31 Correct 3 ms 2644 KB Output is correct
32 Correct 3 ms 2652 KB Output is correct
33 Correct 3 ms 2652 KB Output is correct
34 Correct 3 ms 3168 KB Output is correct
35 Correct 3 ms 3164 KB Output is correct
36 Correct 3 ms 3164 KB Output is correct
37 Correct 3 ms 3164 KB Output is correct
38 Correct 3 ms 3164 KB Output is correct
39 Correct 3 ms 3420 KB Output is correct
40 Correct 3 ms 3164 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 3 ms 3164 KB Output is correct
43 Correct 4 ms 3160 KB Output is correct
44 Correct 4 ms 3160 KB Output is correct
45 Correct 4 ms 3164 KB Output is correct
46 Correct 4 ms 3164 KB Output is correct
47 Correct 4 ms 3160 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 460 KB Output is correct
54 Correct 5 ms 2908 KB Output is correct
55 Correct 5 ms 3024 KB Output is correct
56 Correct 4 ms 2908 KB Output is correct
57 Correct 4 ms 2908 KB Output is correct
58 Correct 4 ms 2912 KB Output is correct
59 Correct 3 ms 2912 KB Output is correct
60 Correct 4 ms 3300 KB Output is correct
61 Correct 4 ms 3416 KB Output is correct
62 Correct 3 ms 3164 KB Output is correct
63 Correct 3 ms 3152 KB Output is correct
64 Correct 4 ms 3216 KB Output is correct
65 Correct 4 ms 3420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 504 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 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 344 KB Output is correct
16 Correct 98 ms 17076 KB Output is correct
17 Correct 106 ms 25676 KB Output is correct
18 Correct 93 ms 24924 KB Output is correct
19 Correct 89 ms 24660 KB Output is correct
20 Correct 92 ms 25512 KB Output is correct
21 Correct 117 ms 25176 KB Output is correct
22 Correct 90 ms 24892 KB Output is correct
23 Correct 89 ms 25028 KB Output is correct
24 Correct 95 ms 27076 KB Output is correct
25 Correct 86 ms 24872 KB Output is correct
26 Correct 91 ms 24532 KB Output is correct
27 Correct 89 ms 25284 KB Output is correct
28 Correct 93 ms 25572 KB Output is correct
29 Correct 96 ms 24260 KB Output is correct
30 Correct 89 ms 24924 KB Output is correct
31 Correct 97 ms 25800 KB Output is correct
32 Correct 94 ms 24924 KB Output is correct
33 Correct 96 ms 25796 KB Output is correct
34 Correct 88 ms 25540 KB Output is correct
35 Correct 97 ms 24260 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 3 ms 3032 KB Output is correct
38 Correct 4 ms 3164 KB Output is correct
39 Correct 3 ms 3164 KB Output is correct
40 Correct 4 ms 3160 KB Output is correct
41 Correct 3 ms 3160 KB Output is correct
42 Correct 4 ms 3140 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 468 KB Output is correct
45 Correct 1 ms 604 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 3 ms 2648 KB Output is correct
50 Correct 3 ms 2652 KB Output is correct
51 Correct 3 ms 2644 KB Output is correct
52 Correct 3 ms 2652 KB Output is correct
53 Correct 3 ms 2652 KB Output is correct
54 Correct 3 ms 3168 KB Output is correct
55 Correct 3 ms 3164 KB Output is correct
56 Correct 3 ms 3164 KB Output is correct
57 Correct 3 ms 3164 KB Output is correct
58 Correct 3 ms 3164 KB Output is correct
59 Correct 3 ms 3420 KB Output is correct
60 Correct 3 ms 3164 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 70 ms 20800 KB Output is correct
63 Correct 71 ms 19836 KB Output is correct
64 Correct 71 ms 20936 KB Output is correct
65 Correct 79 ms 21636 KB Output is correct
66 Correct 74 ms 21704 KB Output is correct
67 Correct 75 ms 21188 KB Output is correct
68 Correct 0 ms 344 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 1 ms 348 KB Output is correct
73 Correct 1 ms 348 KB Output is correct
74 Correct 61 ms 11636 KB Output is correct
75 Correct 61 ms 11624 KB Output is correct
76 Correct 63 ms 11604 KB Output is correct
77 Correct 63 ms 11600 KB Output is correct
78 Correct 79 ms 11664 KB Output is correct
79 Correct 68 ms 13536 KB Output is correct
80 Correct 80 ms 11092 KB Output is correct
81 Correct 70 ms 20308 KB Output is correct
82 Correct 76 ms 22232 KB Output is correct
83 Correct 82 ms 23312 KB Output is correct
84 Correct 74 ms 19396 KB Output is correct
85 Correct 68 ms 20936 KB Output is correct
86 Correct 71 ms 21708 KB Output is correct
87 Correct 65 ms 20680 KB Output is correct
88 Correct 1 ms 600 KB Output is correct
89 Correct 0 ms 348 KB Output is correct
90 Correct 0 ms 348 KB Output is correct
91 Correct 1 ms 348 KB Output is correct
92 Correct 0 ms 348 KB Output is correct
93 Correct 0 ms 464 KB Output is correct
94 Correct 0 ms 348 KB Output is correct
95 Correct 0 ms 344 KB Output is correct
96 Correct 1 ms 348 KB Output is correct
97 Correct 0 ms 464 KB Output is correct
98 Correct 1 ms 348 KB Output is correct
99 Correct 0 ms 348 KB Output is correct
100 Correct 1 ms 348 KB Output is correct
101 Correct 1 ms 348 KB Output is correct
102 Correct 0 ms 348 KB Output is correct
103 Correct 0 ms 348 KB Output is correct
104 Correct 3 ms 3164 KB Output is correct
105 Correct 4 ms 3160 KB Output is correct
106 Correct 4 ms 3160 KB Output is correct
107 Correct 4 ms 3164 KB Output is correct
108 Correct 4 ms 3164 KB Output is correct
109 Correct 4 ms 3160 KB Output is correct
110 Correct 1 ms 348 KB Output is correct
111 Correct 0 ms 348 KB Output is correct
112 Correct 0 ms 348 KB Output is correct
113 Correct 1 ms 348 KB Output is correct
114 Correct 0 ms 348 KB Output is correct
115 Correct 0 ms 460 KB Output is correct
116 Correct 5 ms 2908 KB Output is correct
117 Correct 5 ms 3024 KB Output is correct
118 Correct 4 ms 2908 KB Output is correct
119 Correct 4 ms 2908 KB Output is correct
120 Correct 4 ms 2912 KB Output is correct
121 Correct 3 ms 2912 KB Output is correct
122 Correct 4 ms 3300 KB Output is correct
123 Correct 4 ms 3416 KB Output is correct
124 Correct 3 ms 3164 KB Output is correct
125 Correct 3 ms 3152 KB Output is correct
126 Correct 4 ms 3216 KB Output is correct
127 Correct 4 ms 3420 KB Output is correct
128 Correct 0 ms 360 KB Output is correct
129 Correct 108 ms 23912 KB Output is correct
130 Correct 97 ms 24776 KB Output is correct
131 Correct 99 ms 25796 KB Output is correct
132 Correct 99 ms 25540 KB Output is correct
133 Correct 111 ms 25432 KB Output is correct
134 Correct 97 ms 24568 KB Output is correct
135 Correct 0 ms 348 KB Output is correct
136 Correct 0 ms 348 KB Output is correct
137 Correct 0 ms 352 KB Output is correct
138 Correct 0 ms 348 KB Output is correct
139 Correct 1 ms 348 KB Output is correct
140 Correct 0 ms 348 KB Output is correct
141 Correct 89 ms 16220 KB Output is correct
142 Correct 89 ms 15728 KB Output is correct
143 Correct 91 ms 17360 KB Output is correct
144 Correct 87 ms 15952 KB Output is correct
145 Correct 88 ms 15988 KB Output is correct
146 Correct 137 ms 19908 KB Output is correct
147 Correct 102 ms 20936 KB Output is correct
148 Correct 109 ms 19660 KB Output is correct
149 Correct 92 ms 23908 KB Output is correct
150 Correct 89 ms 25800 KB Output is correct
151 Correct 89 ms 25696 KB Output is correct
152 Correct 95 ms 24548 KB Output is correct
153 Correct 88 ms 25692 KB Output is correct
154 Correct 89 ms 25452 KB Output is correct
155 Correct 92 ms 24772 KB Output is correct