Submission #651047

# Submission time Handle Problem Language Result Execution time Memory
651047 2022-10-16T15:52:30 Z dsyz Fuel Station (NOI20_fuelstation) C++17
100 / 100
166 ms 24740 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1000005)
int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);
	ll N,D;
	cin>>N>>D;
	N++;
	pair<ll,pair<ll,ll> > arr[N];
	for(ll i = 0;i < N - 1;i++){
		cin>>arr[i].first>>arr[i].second.first>>arr[i].second.second;
	}
	arr[N - 1].first = D, arr[N - 1].second.first = 0, arr[N - 1].second.second = 0;
	ll F = 0;
	ll cur = 0; //F + all A[i]
	sort(arr,arr + N);
	priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > > pq;
	for(ll i = 0;i < N;i++){
		if(cur < arr[i].first){
			F += arr[i].first - cur;
			cur = arr[i].first;
		}
		while(!pq.empty() && pq.top().first < F){
			cur -= pq.top().second;
			pq.pop();
			if(cur < arr[i].first){
				F += arr[i].first - cur;
				cur = arr[i].first;
			}
		}
		if(F <= arr[i].second.second){
			cur += arr[i].second.first;
			pq.push(make_pair(arr[i].second.second,arr[i].second.first));
		}
	}
	cout<<F<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 316 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 146 ms 24336 KB Output is correct
2 Correct 146 ms 24088 KB Output is correct
3 Correct 142 ms 23968 KB Output is correct
4 Correct 142 ms 24096 KB Output is correct
5 Correct 134 ms 24600 KB Output is correct
6 Correct 134 ms 23456 KB Output is correct
7 Correct 139 ms 23576 KB Output is correct
8 Correct 141 ms 23960 KB Output is correct
9 Correct 143 ms 24740 KB Output is correct
10 Correct 148 ms 23456 KB Output is correct
11 Correct 140 ms 23456 KB Output is correct
12 Correct 140 ms 24096 KB Output is correct
13 Correct 134 ms 23448 KB Output is correct
14 Correct 145 ms 24092 KB Output is correct
15 Correct 166 ms 24084 KB Output is correct
16 Correct 134 ms 24728 KB Output is correct
17 Correct 136 ms 24688 KB Output is correct
18 Correct 136 ms 24092 KB Output is correct
19 Correct 137 ms 24104 KB Output is correct
20 Correct 139 ms 24128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 5 ms 984 KB Output is correct
3 Correct 4 ms 1048 KB Output is correct
4 Correct 4 ms 984 KB Output is correct
5 Correct 4 ms 980 KB Output is correct
6 Correct 4 ms 972 KB Output is correct
7 Correct 4 ms 984 KB Output is correct
8 Correct 0 ms 320 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 320 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 4 ms 584 KB Output is correct
16 Correct 3 ms 596 KB Output is correct
17 Correct 3 ms 596 KB Output is correct
18 Correct 3 ms 596 KB Output is correct
19 Correct 4 ms 972 KB Output is correct
20 Correct 5 ms 1132 KB Output is correct
21 Correct 5 ms 1044 KB Output is correct
22 Correct 4 ms 976 KB Output is correct
23 Correct 4 ms 1072 KB Output is correct
24 Correct 4 ms 984 KB Output is correct
25 Correct 4 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 5 ms 984 KB Output is correct
3 Correct 4 ms 1048 KB Output is correct
4 Correct 4 ms 984 KB Output is correct
5 Correct 4 ms 980 KB Output is correct
6 Correct 4 ms 972 KB Output is correct
7 Correct 4 ms 984 KB Output is correct
8 Correct 0 ms 320 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 320 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 4 ms 584 KB Output is correct
16 Correct 3 ms 596 KB Output is correct
17 Correct 3 ms 596 KB Output is correct
18 Correct 3 ms 596 KB Output is correct
19 Correct 4 ms 972 KB Output is correct
20 Correct 5 ms 1132 KB Output is correct
21 Correct 5 ms 1044 KB Output is correct
22 Correct 4 ms 976 KB Output is correct
23 Correct 4 ms 1072 KB Output is correct
24 Correct 4 ms 984 KB Output is correct
25 Correct 4 ms 1108 KB Output is correct
26 Correct 0 ms 324 KB Output is correct
27 Correct 108 ms 19904 KB Output is correct
28 Correct 108 ms 19736 KB Output is correct
29 Correct 106 ms 19392 KB Output is correct
30 Correct 133 ms 19492 KB Output is correct
31 Correct 106 ms 19984 KB Output is correct
32 Correct 105 ms 19732 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 320 KB Output is correct
35 Correct 1 ms 320 KB Output is correct
36 Correct 1 ms 320 KB Output is correct
37 Correct 1 ms 320 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 93 ms 11688 KB Output is correct
40 Correct 98 ms 11564 KB Output is correct
41 Correct 92 ms 11680 KB Output is correct
42 Correct 95 ms 11724 KB Output is correct
43 Correct 92 ms 11560 KB Output is correct
44 Correct 94 ms 13344 KB Output is correct
45 Correct 87 ms 11184 KB Output is correct
46 Correct 105 ms 20028 KB Output is correct
47 Correct 120 ms 21532 KB Output is correct
48 Correct 123 ms 21440 KB Output is correct
49 Correct 107 ms 19352 KB Output is correct
50 Correct 106 ms 19864 KB Output is correct
51 Correct 106 ms 19768 KB Output is correct
52 Correct 102 ms 19472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 316 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 316 KB Output is correct
23 Correct 1 ms 316 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 320 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 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 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 316 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 5 ms 984 KB Output is correct
18 Correct 4 ms 1048 KB Output is correct
19 Correct 4 ms 984 KB Output is correct
20 Correct 4 ms 980 KB Output is correct
21 Correct 4 ms 972 KB Output is correct
22 Correct 4 ms 984 KB Output is correct
23 Correct 0 ms 320 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 320 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 320 KB Output is correct
29 Correct 3 ms 596 KB Output is correct
30 Correct 4 ms 584 KB Output is correct
31 Correct 3 ms 596 KB Output is correct
32 Correct 3 ms 596 KB Output is correct
33 Correct 3 ms 596 KB Output is correct
34 Correct 4 ms 972 KB Output is correct
35 Correct 5 ms 1132 KB Output is correct
36 Correct 5 ms 1044 KB Output is correct
37 Correct 4 ms 976 KB Output is correct
38 Correct 4 ms 1072 KB Output is correct
39 Correct 4 ms 984 KB Output is correct
40 Correct 4 ms 1108 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 5 ms 1108 KB Output is correct
43 Correct 5 ms 1104 KB Output is correct
44 Correct 6 ms 1184 KB Output is correct
45 Correct 5 ms 1228 KB Output is correct
46 Correct 5 ms 1112 KB Output is correct
47 Correct 6 ms 1228 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 320 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 4 ms 852 KB Output is correct
55 Correct 4 ms 980 KB Output is correct
56 Correct 4 ms 844 KB Output is correct
57 Correct 4 ms 844 KB Output is correct
58 Correct 4 ms 840 KB Output is correct
59 Correct 5 ms 712 KB Output is correct
60 Correct 5 ms 1240 KB Output is correct
61 Correct 5 ms 1236 KB Output is correct
62 Correct 5 ms 1112 KB Output is correct
63 Correct 5 ms 932 KB Output is correct
64 Correct 5 ms 1208 KB Output is correct
65 Correct 4 ms 1096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 316 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 146 ms 24336 KB Output is correct
17 Correct 146 ms 24088 KB Output is correct
18 Correct 142 ms 23968 KB Output is correct
19 Correct 142 ms 24096 KB Output is correct
20 Correct 134 ms 24600 KB Output is correct
21 Correct 134 ms 23456 KB Output is correct
22 Correct 139 ms 23576 KB Output is correct
23 Correct 141 ms 23960 KB Output is correct
24 Correct 143 ms 24740 KB Output is correct
25 Correct 148 ms 23456 KB Output is correct
26 Correct 140 ms 23456 KB Output is correct
27 Correct 140 ms 24096 KB Output is correct
28 Correct 134 ms 23448 KB Output is correct
29 Correct 145 ms 24092 KB Output is correct
30 Correct 166 ms 24084 KB Output is correct
31 Correct 134 ms 24728 KB Output is correct
32 Correct 136 ms 24688 KB Output is correct
33 Correct 136 ms 24092 KB Output is correct
34 Correct 137 ms 24104 KB Output is correct
35 Correct 139 ms 24128 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 5 ms 984 KB Output is correct
38 Correct 4 ms 1048 KB Output is correct
39 Correct 4 ms 984 KB Output is correct
40 Correct 4 ms 980 KB Output is correct
41 Correct 4 ms 972 KB Output is correct
42 Correct 4 ms 984 KB Output is correct
43 Correct 0 ms 320 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 0 ms 320 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 320 KB Output is correct
49 Correct 3 ms 596 KB Output is correct
50 Correct 4 ms 584 KB Output is correct
51 Correct 3 ms 596 KB Output is correct
52 Correct 3 ms 596 KB Output is correct
53 Correct 3 ms 596 KB Output is correct
54 Correct 4 ms 972 KB Output is correct
55 Correct 5 ms 1132 KB Output is correct
56 Correct 5 ms 1044 KB Output is correct
57 Correct 4 ms 976 KB Output is correct
58 Correct 4 ms 1072 KB Output is correct
59 Correct 4 ms 984 KB Output is correct
60 Correct 4 ms 1108 KB Output is correct
61 Correct 0 ms 324 KB Output is correct
62 Correct 108 ms 19904 KB Output is correct
63 Correct 108 ms 19736 KB Output is correct
64 Correct 106 ms 19392 KB Output is correct
65 Correct 133 ms 19492 KB Output is correct
66 Correct 106 ms 19984 KB Output is correct
67 Correct 105 ms 19732 KB Output is correct
68 Correct 0 ms 212 KB Output is correct
69 Correct 1 ms 320 KB Output is correct
70 Correct 1 ms 320 KB Output is correct
71 Correct 1 ms 320 KB Output is correct
72 Correct 1 ms 320 KB Output is correct
73 Correct 1 ms 212 KB Output is correct
74 Correct 93 ms 11688 KB Output is correct
75 Correct 98 ms 11564 KB Output is correct
76 Correct 92 ms 11680 KB Output is correct
77 Correct 95 ms 11724 KB Output is correct
78 Correct 92 ms 11560 KB Output is correct
79 Correct 94 ms 13344 KB Output is correct
80 Correct 87 ms 11184 KB Output is correct
81 Correct 105 ms 20028 KB Output is correct
82 Correct 120 ms 21532 KB Output is correct
83 Correct 123 ms 21440 KB Output is correct
84 Correct 107 ms 19352 KB Output is correct
85 Correct 106 ms 19864 KB Output is correct
86 Correct 106 ms 19768 KB Output is correct
87 Correct 102 ms 19472 KB Output is correct
88 Correct 0 ms 212 KB Output is correct
89 Correct 1 ms 212 KB Output is correct
90 Correct 1 ms 316 KB Output is correct
91 Correct 1 ms 212 KB Output is correct
92 Correct 1 ms 320 KB Output is correct
93 Correct 1 ms 212 KB Output is correct
94 Correct 1 ms 316 KB Output is correct
95 Correct 1 ms 316 KB Output is correct
96 Correct 0 ms 212 KB Output is correct
97 Correct 0 ms 212 KB Output is correct
98 Correct 0 ms 212 KB Output is correct
99 Correct 1 ms 212 KB Output is correct
100 Correct 1 ms 320 KB Output is correct
101 Correct 1 ms 212 KB Output is correct
102 Correct 1 ms 212 KB Output is correct
103 Correct 1 ms 212 KB Output is correct
104 Correct 5 ms 1108 KB Output is correct
105 Correct 5 ms 1104 KB Output is correct
106 Correct 6 ms 1184 KB Output is correct
107 Correct 5 ms 1228 KB Output is correct
108 Correct 5 ms 1112 KB Output is correct
109 Correct 6 ms 1228 KB Output is correct
110 Correct 1 ms 212 KB Output is correct
111 Correct 1 ms 212 KB Output is correct
112 Correct 1 ms 320 KB Output is correct
113 Correct 1 ms 212 KB Output is correct
114 Correct 1 ms 212 KB Output is correct
115 Correct 1 ms 212 KB Output is correct
116 Correct 4 ms 852 KB Output is correct
117 Correct 4 ms 980 KB Output is correct
118 Correct 4 ms 844 KB Output is correct
119 Correct 4 ms 844 KB Output is correct
120 Correct 4 ms 840 KB Output is correct
121 Correct 5 ms 712 KB Output is correct
122 Correct 5 ms 1240 KB Output is correct
123 Correct 5 ms 1236 KB Output is correct
124 Correct 5 ms 1112 KB Output is correct
125 Correct 5 ms 932 KB Output is correct
126 Correct 5 ms 1208 KB Output is correct
127 Correct 4 ms 1096 KB Output is correct
128 Correct 1 ms 212 KB Output is correct
129 Correct 130 ms 23068 KB Output is correct
130 Correct 128 ms 23740 KB Output is correct
131 Correct 129 ms 24376 KB Output is correct
132 Correct 123 ms 23780 KB Output is correct
133 Correct 126 ms 23744 KB Output is correct
134 Correct 136 ms 24364 KB Output is correct
135 Correct 1 ms 212 KB Output is correct
136 Correct 0 ms 212 KB Output is correct
137 Correct 1 ms 284 KB Output is correct
138 Correct 1 ms 212 KB Output is correct
139 Correct 0 ms 212 KB Output is correct
140 Correct 1 ms 212 KB Output is correct
141 Correct 117 ms 16044 KB Output is correct
142 Correct 122 ms 15664 KB Output is correct
143 Correct 124 ms 17224 KB Output is correct
144 Correct 114 ms 16036 KB Output is correct
145 Correct 122 ms 16076 KB Output is correct
146 Correct 149 ms 18572 KB Output is correct
147 Correct 133 ms 19368 KB Output is correct
148 Correct 138 ms 18848 KB Output is correct
149 Correct 132 ms 23708 KB Output is correct
150 Correct 144 ms 24088 KB Output is correct
151 Correct 143 ms 24128 KB Output is correct
152 Correct 133 ms 23696 KB Output is correct
153 Correct 136 ms 23708 KB Output is correct
154 Correct 137 ms 23716 KB Output is correct
155 Correct 135 ms 23708 KB Output is correct