Submission #799171

# Submission time Handle Problem Language Result Execution time Memory
799171 2023-07-31T10:28:19 Z AndiR Fuel Station (NOI20_fuelstation) C++14
100 / 100
287 ms 24704 KB
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll Nmax=300000;

ll n, d;
struct station{
    ll x, a, b;
}v[Nmax+1];
priority_queue <pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> q;

bool cmp(station a, station b){
    return a.x<b.x;
}
int main()
{
    cin>>n>>d;
    for (ll i=0; i<n; i++)
        cin>>v[i].x>>v[i].a>>v[i].b;
    sort(v, v+n, cmp);
    v[n].x=d; v[n].b=d+1;
    ll fs=0, fadd=0;
    for (ll i=0; i<=n; i++){
        while (v[i].x>fs+fadd && fs<=v[i].b){
            fs=v[i].x-fadd;
            while (!q.empty() && q.top().first<fs){
                fadd-=q.top().second;
                q.pop();
            }
        }
        if (fs<=v[i].b){
            fadd+=v[i].a;
            q.push({v[i].b, v[i].a});
        }
    }
    cout<<fs;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 308 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 273 ms 15884 KB Output is correct
2 Correct 274 ms 24200 KB Output is correct
3 Correct 275 ms 23964 KB Output is correct
4 Correct 267 ms 24076 KB Output is correct
5 Correct 278 ms 24604 KB Output is correct
6 Correct 259 ms 23428 KB Output is correct
7 Correct 261 ms 23428 KB Output is correct
8 Correct 273 ms 23984 KB Output is correct
9 Correct 287 ms 24616 KB Output is correct
10 Correct 256 ms 23476 KB Output is correct
11 Correct 262 ms 23416 KB Output is correct
12 Correct 271 ms 23992 KB Output is correct
13 Correct 267 ms 23468 KB Output is correct
14 Correct 273 ms 24072 KB Output is correct
15 Correct 268 ms 24112 KB Output is correct
16 Correct 279 ms 24684 KB Output is correct
17 Correct 275 ms 24704 KB Output is correct
18 Correct 271 ms 24072 KB Output is correct
19 Correct 264 ms 24096 KB Output is correct
20 Correct 280 ms 24064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 6 ms 980 KB Output is correct
3 Correct 7 ms 980 KB Output is correct
4 Correct 6 ms 980 KB Output is correct
5 Correct 6 ms 980 KB Output is correct
6 Correct 7 ms 960 KB Output is correct
7 Correct 7 ms 980 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 312 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 6 ms 572 KB Output is correct
15 Correct 6 ms 596 KB Output is correct
16 Correct 7 ms 684 KB Output is correct
17 Correct 6 ms 596 KB Output is correct
18 Correct 8 ms 684 KB Output is correct
19 Correct 6 ms 960 KB Output is correct
20 Correct 8 ms 1072 KB Output is correct
21 Correct 7 ms 1008 KB Output is correct
22 Correct 6 ms 1060 KB Output is correct
23 Correct 6 ms 980 KB Output is correct
24 Correct 7 ms 980 KB Output is correct
25 Correct 6 ms 1032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 6 ms 980 KB Output is correct
3 Correct 7 ms 980 KB Output is correct
4 Correct 6 ms 980 KB Output is correct
5 Correct 6 ms 980 KB Output is correct
6 Correct 7 ms 960 KB Output is correct
7 Correct 7 ms 980 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 312 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 6 ms 572 KB Output is correct
15 Correct 6 ms 596 KB Output is correct
16 Correct 7 ms 684 KB Output is correct
17 Correct 6 ms 596 KB Output is correct
18 Correct 8 ms 684 KB Output is correct
19 Correct 6 ms 960 KB Output is correct
20 Correct 8 ms 1072 KB Output is correct
21 Correct 7 ms 1008 KB Output is correct
22 Correct 6 ms 1060 KB Output is correct
23 Correct 6 ms 980 KB Output is correct
24 Correct 7 ms 980 KB Output is correct
25 Correct 6 ms 1032 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 182 ms 15884 KB Output is correct
28 Correct 182 ms 15824 KB Output is correct
29 Correct 173 ms 15832 KB Output is correct
30 Correct 173 ms 15900 KB Output is correct
31 Correct 187 ms 15924 KB Output is correct
32 Correct 186 ms 15892 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 304 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 308 KB Output is correct
39 Correct 172 ms 7524 KB Output is correct
40 Correct 174 ms 7472 KB Output is correct
41 Correct 172 ms 7500 KB Output is correct
42 Correct 173 ms 7636 KB Output is correct
43 Correct 176 ms 7580 KB Output is correct
44 Correct 177 ms 9832 KB Output is correct
45 Correct 164 ms 7952 KB Output is correct
46 Correct 185 ms 15936 KB Output is correct
47 Correct 212 ms 15904 KB Output is correct
48 Correct 212 ms 15916 KB Output is correct
49 Correct 165 ms 15928 KB Output is correct
50 Correct 180 ms 15928 KB Output is correct
51 Correct 178 ms 15928 KB Output is correct
52 Correct 165 ms 15820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 308 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 308 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 304 KB Output is correct
20 Correct 0 ms 308 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 308 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 308 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 6 ms 980 KB Output is correct
18 Correct 7 ms 980 KB Output is correct
19 Correct 6 ms 980 KB Output is correct
20 Correct 6 ms 980 KB Output is correct
21 Correct 7 ms 960 KB Output is correct
22 Correct 7 ms 980 KB Output is correct
23 Correct 0 ms 304 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 312 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 6 ms 572 KB Output is correct
30 Correct 6 ms 596 KB Output is correct
31 Correct 7 ms 684 KB Output is correct
32 Correct 6 ms 596 KB Output is correct
33 Correct 8 ms 684 KB Output is correct
34 Correct 6 ms 960 KB Output is correct
35 Correct 8 ms 1072 KB Output is correct
36 Correct 7 ms 1008 KB Output is correct
37 Correct 6 ms 1060 KB Output is correct
38 Correct 6 ms 980 KB Output is correct
39 Correct 7 ms 980 KB Output is correct
40 Correct 6 ms 1032 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 8 ms 1144 KB Output is correct
43 Correct 9 ms 1108 KB Output is correct
44 Correct 10 ms 1148 KB Output is correct
45 Correct 9 ms 1200 KB Output is correct
46 Correct 9 ms 1108 KB Output is correct
47 Correct 10 ms 1216 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 312 KB Output is correct
50 Correct 0 ms 316 KB Output is correct
51 Correct 1 ms 312 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 1 ms 308 KB Output is correct
54 Correct 9 ms 852 KB Output is correct
55 Correct 9 ms 852 KB Output is correct
56 Correct 9 ms 744 KB Output is correct
57 Correct 9 ms 848 KB Output is correct
58 Correct 9 ms 952 KB Output is correct
59 Correct 8 ms 684 KB Output is correct
60 Correct 10 ms 1236 KB Output is correct
61 Correct 10 ms 1220 KB Output is correct
62 Correct 9 ms 1108 KB Output is correct
63 Correct 8 ms 1028 KB Output is correct
64 Correct 9 ms 1108 KB Output is correct
65 Correct 8 ms 1092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 308 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 308 KB Output is correct
16 Correct 273 ms 15884 KB Output is correct
17 Correct 274 ms 24200 KB Output is correct
18 Correct 275 ms 23964 KB Output is correct
19 Correct 267 ms 24076 KB Output is correct
20 Correct 278 ms 24604 KB Output is correct
21 Correct 259 ms 23428 KB Output is correct
22 Correct 261 ms 23428 KB Output is correct
23 Correct 273 ms 23984 KB Output is correct
24 Correct 287 ms 24616 KB Output is correct
25 Correct 256 ms 23476 KB Output is correct
26 Correct 262 ms 23416 KB Output is correct
27 Correct 271 ms 23992 KB Output is correct
28 Correct 267 ms 23468 KB Output is correct
29 Correct 273 ms 24072 KB Output is correct
30 Correct 268 ms 24112 KB Output is correct
31 Correct 279 ms 24684 KB Output is correct
32 Correct 275 ms 24704 KB Output is correct
33 Correct 271 ms 24072 KB Output is correct
34 Correct 264 ms 24096 KB Output is correct
35 Correct 280 ms 24064 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 6 ms 980 KB Output is correct
38 Correct 7 ms 980 KB Output is correct
39 Correct 6 ms 980 KB Output is correct
40 Correct 6 ms 980 KB Output is correct
41 Correct 7 ms 960 KB Output is correct
42 Correct 7 ms 980 KB Output is correct
43 Correct 0 ms 304 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 312 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 6 ms 572 KB Output is correct
50 Correct 6 ms 596 KB Output is correct
51 Correct 7 ms 684 KB Output is correct
52 Correct 6 ms 596 KB Output is correct
53 Correct 8 ms 684 KB Output is correct
54 Correct 6 ms 960 KB Output is correct
55 Correct 8 ms 1072 KB Output is correct
56 Correct 7 ms 1008 KB Output is correct
57 Correct 6 ms 1060 KB Output is correct
58 Correct 6 ms 980 KB Output is correct
59 Correct 7 ms 980 KB Output is correct
60 Correct 6 ms 1032 KB Output is correct
61 Correct 0 ms 212 KB Output is correct
62 Correct 182 ms 15884 KB Output is correct
63 Correct 182 ms 15824 KB Output is correct
64 Correct 173 ms 15832 KB Output is correct
65 Correct 173 ms 15900 KB Output is correct
66 Correct 187 ms 15924 KB Output is correct
67 Correct 186 ms 15892 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 0 ms 212 KB Output is correct
70 Correct 0 ms 304 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 0 ms 212 KB Output is correct
73 Correct 0 ms 308 KB Output is correct
74 Correct 172 ms 7524 KB Output is correct
75 Correct 174 ms 7472 KB Output is correct
76 Correct 172 ms 7500 KB Output is correct
77 Correct 173 ms 7636 KB Output is correct
78 Correct 176 ms 7580 KB Output is correct
79 Correct 177 ms 9832 KB Output is correct
80 Correct 164 ms 7952 KB Output is correct
81 Correct 185 ms 15936 KB Output is correct
82 Correct 212 ms 15904 KB Output is correct
83 Correct 212 ms 15916 KB Output is correct
84 Correct 165 ms 15928 KB Output is correct
85 Correct 180 ms 15928 KB Output is correct
86 Correct 178 ms 15928 KB Output is correct
87 Correct 165 ms 15820 KB Output is correct
88 Correct 0 ms 212 KB Output is correct
89 Correct 0 ms 212 KB Output is correct
90 Correct 0 ms 212 KB Output is correct
91 Correct 0 ms 304 KB Output is correct
92 Correct 0 ms 308 KB Output is correct
93 Correct 0 ms 212 KB Output is correct
94 Correct 0 ms 212 KB Output is correct
95 Correct 0 ms 212 KB Output is correct
96 Correct 0 ms 212 KB Output is correct
97 Correct 1 ms 212 KB Output is correct
98 Correct 1 ms 212 KB Output is correct
99 Correct 0 ms 212 KB Output is correct
100 Correct 0 ms 212 KB Output is correct
101 Correct 0 ms 212 KB Output is correct
102 Correct 0 ms 212 KB Output is correct
103 Correct 1 ms 212 KB Output is correct
104 Correct 8 ms 1144 KB Output is correct
105 Correct 9 ms 1108 KB Output is correct
106 Correct 10 ms 1148 KB Output is correct
107 Correct 9 ms 1200 KB Output is correct
108 Correct 9 ms 1108 KB Output is correct
109 Correct 10 ms 1216 KB Output is correct
110 Correct 0 ms 212 KB Output is correct
111 Correct 0 ms 312 KB Output is correct
112 Correct 0 ms 316 KB Output is correct
113 Correct 1 ms 312 KB Output is correct
114 Correct 0 ms 212 KB Output is correct
115 Correct 1 ms 308 KB Output is correct
116 Correct 9 ms 852 KB Output is correct
117 Correct 9 ms 852 KB Output is correct
118 Correct 9 ms 744 KB Output is correct
119 Correct 9 ms 848 KB Output is correct
120 Correct 9 ms 952 KB Output is correct
121 Correct 8 ms 684 KB Output is correct
122 Correct 10 ms 1236 KB Output is correct
123 Correct 10 ms 1220 KB Output is correct
124 Correct 9 ms 1108 KB Output is correct
125 Correct 8 ms 1028 KB Output is correct
126 Correct 9 ms 1108 KB Output is correct
127 Correct 8 ms 1092 KB Output is correct
128 Correct 0 ms 212 KB Output is correct
129 Correct 260 ms 23056 KB Output is correct
130 Correct 280 ms 23708 KB Output is correct
131 Correct 285 ms 24340 KB Output is correct
132 Correct 273 ms 23692 KB Output is correct
133 Correct 268 ms 23704 KB Output is correct
134 Correct 284 ms 24372 KB Output is correct
135 Correct 0 ms 212 KB Output is correct
136 Correct 0 ms 312 KB Output is correct
137 Correct 1 ms 216 KB Output is correct
138 Correct 0 ms 212 KB Output is correct
139 Correct 0 ms 212 KB Output is correct
140 Correct 0 ms 212 KB Output is correct
141 Correct 281 ms 15956 KB Output is correct
142 Correct 264 ms 15692 KB Output is correct
143 Correct 273 ms 17156 KB Output is correct
144 Correct 274 ms 16008 KB Output is correct
145 Correct 274 ms 16040 KB Output is correct
146 Correct 273 ms 18476 KB Output is correct
147 Correct 273 ms 19344 KB Output is correct
148 Correct 279 ms 18800 KB Output is correct
149 Correct 263 ms 23684 KB Output is correct
150 Correct 265 ms 24064 KB Output is correct
151 Correct 270 ms 24092 KB Output is correct
152 Correct 271 ms 23660 KB Output is correct
153 Correct 260 ms 23764 KB Output is correct
154 Correct 264 ms 23736 KB Output is correct
155 Correct 263 ms 23732 KB Output is correct