답안 #903843

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
903843 2024-01-11T12:15:13 Z pcc Fuel Station (NOI20_fuelstation) C++14
100 / 100
512 ms 59964 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
#define ls (now*2+1)
#define rs (now*2+2)
#define mid ((l+r)>>1)


const int mxn = 3e5+10;
ll N,L;
pll segtree[mxn*12];
pair<ll,pll> arr[mxn];
vector<pll> v;
vector<int> all;

void modify(int now,int l,int r,int s,int e,ll v){
	if(l>=s&&e>=r){
		segtree[now].sc += v;
		return;
	}
	if(mid>=s)modify(now*2+1,l,mid,s,e,v);
	if(mid<e)modify(now*2+2,mid+1,r,s,e,v);
	segtree[now].fs = min(segtree[ls].fs+segtree[ls].sc,segtree[rs].fs+segtree[rs].sc);
}


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>N>>L;
	for(int i = 1;i<=N;i++){
		cin>>arr[i].fs>>arr[i].sc.fs>>arr[i].sc.sc;
		v.push_back(make_pair(arr[i].sc.sc,i));
		all.push_back(arr[i].fs);
		all.push_back(arr[i].fs+1);
		if(arr[i].fs-1>0)all.push_back(arr[i].fs-1);
	}
	all.push_back(0);
	all.push_back(L);
	sort(all.begin(),all.end());
	all.resize(unique(all.begin(),all.end())-all.begin());
	while(all.back()>L)all.pop_back();
	ll len = all.size();
	for(int i = 0;i<len;i++){
		modify(0,0,len,i,i,-all[i]);
	}
	ll ans = L;
	sort(v.rbegin(),v.rend());
	v.push_back(make_pair(0,0));
	//for(auto &i:all)cout<<i<<',';cout<<endl;
	for(int i = 0;i+1<v.size();i++){
		int now = v[i].sc;
		int p = lower_bound(all.begin(),all.end(),arr[now].fs)-all.begin();
		modify(0,0,len,p+1,len,arr[now].sc.fs);
		ll tans = max(-(segtree[0].fs+segtree[0].sc),v[i+1].fs);
		//cout<<v[i].fs<<":"<<now<<","<<p<<" "<<tans<<endl;
		if(v[i].fs>=tans)ans = min(ans,tans);
	}
	cout<<ans;
}

Compilation message

FuelStation.cpp: In function 'int main()':
FuelStation.cpp:56:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  for(int i = 0;i+1<v.size();i++){
      |                ~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2408 KB Output is correct
3 Correct 1 ms 2408 KB Output is correct
4 Correct 1 ms 2408 KB Output is correct
5 Correct 1 ms 2408 KB Output is correct
6 Correct 1 ms 2520 KB Output is correct
7 Correct 1 ms 2408 KB Output is correct
8 Correct 1 ms 2552 KB Output is correct
9 Correct 1 ms 2512 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2512 KB Output is correct
12 Correct 1 ms 2516 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 208 ms 27032 KB Output is correct
2 Correct 202 ms 26548 KB Output is correct
3 Correct 208 ms 26548 KB Output is correct
4 Correct 163 ms 27124 KB Output is correct
5 Correct 190 ms 27152 KB Output is correct
6 Correct 225 ms 26408 KB Output is correct
7 Correct 209 ms 26536 KB Output is correct
8 Correct 175 ms 27780 KB Output is correct
9 Correct 215 ms 29332 KB Output is correct
10 Correct 157 ms 26544 KB Output is correct
11 Correct 221 ms 28208 KB Output is correct
12 Correct 165 ms 26816 KB Output is correct
13 Correct 199 ms 27000 KB Output is correct
14 Correct 221 ms 28560 KB Output is correct
15 Correct 159 ms 27172 KB Output is correct
16 Correct 216 ms 28632 KB Output is correct
17 Correct 174 ms 27336 KB Output is correct
18 Correct 209 ms 27048 KB Output is correct
19 Correct 169 ms 26792 KB Output is correct
20 Correct 214 ms 28008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 7 ms 5080 KB Output is correct
3 Correct 13 ms 5240 KB Output is correct
4 Correct 8 ms 5092 KB Output is correct
5 Correct 9 ms 5076 KB Output is correct
6 Correct 8 ms 5208 KB Output is correct
7 Correct 10 ms 5092 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2520 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 8 ms 5080 KB Output is correct
15 Correct 6 ms 5076 KB Output is correct
16 Correct 7 ms 5080 KB Output is correct
17 Correct 7 ms 5116 KB Output is correct
18 Correct 8 ms 5076 KB Output is correct
19 Correct 6 ms 5080 KB Output is correct
20 Correct 9 ms 5168 KB Output is correct
21 Correct 9 ms 5320 KB Output is correct
22 Correct 6 ms 5076 KB Output is correct
23 Correct 7 ms 5080 KB Output is correct
24 Correct 8 ms 5080 KB Output is correct
25 Correct 9 ms 5092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 7 ms 5080 KB Output is correct
3 Correct 13 ms 5240 KB Output is correct
4 Correct 8 ms 5092 KB Output is correct
5 Correct 9 ms 5076 KB Output is correct
6 Correct 8 ms 5208 KB Output is correct
7 Correct 10 ms 5092 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2520 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 8 ms 5080 KB Output is correct
15 Correct 6 ms 5076 KB Output is correct
16 Correct 7 ms 5080 KB Output is correct
17 Correct 7 ms 5116 KB Output is correct
18 Correct 8 ms 5076 KB Output is correct
19 Correct 6 ms 5080 KB Output is correct
20 Correct 9 ms 5168 KB Output is correct
21 Correct 9 ms 5320 KB Output is correct
22 Correct 6 ms 5076 KB Output is correct
23 Correct 7 ms 5080 KB Output is correct
24 Correct 8 ms 5080 KB Output is correct
25 Correct 9 ms 5092 KB Output is correct
26 Correct 1 ms 2520 KB Output is correct
27 Correct 204 ms 22892 KB Output is correct
28 Correct 209 ms 23984 KB Output is correct
29 Correct 211 ms 23212 KB Output is correct
30 Correct 204 ms 22812 KB Output is correct
31 Correct 205 ms 23720 KB Output is correct
32 Correct 206 ms 22844 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 180 ms 23628 KB Output is correct
40 Correct 185 ms 23472 KB Output is correct
41 Correct 216 ms 23196 KB Output is correct
42 Correct 172 ms 22860 KB Output is correct
43 Correct 203 ms 23976 KB Output is correct
44 Correct 169 ms 23496 KB Output is correct
45 Correct 190 ms 22188 KB Output is correct
46 Correct 177 ms 23984 KB Output is correct
47 Correct 153 ms 24668 KB Output is correct
48 Correct 150 ms 24556 KB Output is correct
49 Correct 185 ms 23320 KB Output is correct
50 Correct 198 ms 23756 KB Output is correct
51 Correct 171 ms 22700 KB Output is correct
52 Correct 198 ms 23364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2408 KB Output is correct
3 Correct 1 ms 2408 KB Output is correct
4 Correct 1 ms 2408 KB Output is correct
5 Correct 1 ms 2408 KB Output is correct
6 Correct 1 ms 2520 KB Output is correct
7 Correct 1 ms 2408 KB Output is correct
8 Correct 1 ms 2552 KB Output is correct
9 Correct 1 ms 2512 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2512 KB Output is correct
12 Correct 1 ms 2516 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2408 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2392 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2512 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2508 KB Output is correct
28 Correct 1 ms 2512 KB Output is correct
29 Correct 1 ms 2392 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2408 KB Output is correct
3 Correct 1 ms 2408 KB Output is correct
4 Correct 1 ms 2408 KB Output is correct
5 Correct 1 ms 2408 KB Output is correct
6 Correct 1 ms 2520 KB Output is correct
7 Correct 1 ms 2408 KB Output is correct
8 Correct 1 ms 2552 KB Output is correct
9 Correct 1 ms 2512 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2512 KB Output is correct
12 Correct 1 ms 2516 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 7 ms 5080 KB Output is correct
18 Correct 13 ms 5240 KB Output is correct
19 Correct 8 ms 5092 KB Output is correct
20 Correct 9 ms 5076 KB Output is correct
21 Correct 8 ms 5208 KB Output is correct
22 Correct 10 ms 5092 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2520 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 8 ms 5080 KB Output is correct
30 Correct 6 ms 5076 KB Output is correct
31 Correct 7 ms 5080 KB Output is correct
32 Correct 7 ms 5116 KB Output is correct
33 Correct 8 ms 5076 KB Output is correct
34 Correct 6 ms 5080 KB Output is correct
35 Correct 9 ms 5168 KB Output is correct
36 Correct 9 ms 5320 KB Output is correct
37 Correct 6 ms 5076 KB Output is correct
38 Correct 7 ms 5080 KB Output is correct
39 Correct 8 ms 5080 KB Output is correct
40 Correct 9 ms 5092 KB Output is correct
41 Correct 1 ms 2392 KB Output is correct
42 Correct 8 ms 5336 KB Output is correct
43 Correct 11 ms 5332 KB Output is correct
44 Correct 11 ms 5332 KB Output is correct
45 Correct 11 ms 5336 KB Output is correct
46 Correct 11 ms 5336 KB Output is correct
47 Correct 11 ms 5336 KB Output is correct
48 Correct 1 ms 2404 KB Output is correct
49 Correct 1 ms 2404 KB Output is correct
50 Correct 1 ms 2404 KB Output is correct
51 Correct 1 ms 2404 KB Output is correct
52 Correct 1 ms 2516 KB Output is correct
53 Correct 1 ms 2408 KB Output is correct
54 Correct 11 ms 5216 KB Output is correct
55 Correct 11 ms 5348 KB Output is correct
56 Correct 13 ms 5604 KB Output is correct
57 Correct 12 ms 5348 KB Output is correct
58 Correct 11 ms 5348 KB Output is correct
59 Correct 7 ms 5332 KB Output is correct
60 Correct 7 ms 5336 KB Output is correct
61 Correct 7 ms 5336 KB Output is correct
62 Correct 7 ms 5336 KB Output is correct
63 Correct 10 ms 5336 KB Output is correct
64 Correct 8 ms 5336 KB Output is correct
65 Correct 8 ms 5336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2408 KB Output is correct
3 Correct 1 ms 2408 KB Output is correct
4 Correct 1 ms 2408 KB Output is correct
5 Correct 1 ms 2408 KB Output is correct
6 Correct 1 ms 2520 KB Output is correct
7 Correct 1 ms 2408 KB Output is correct
8 Correct 1 ms 2552 KB Output is correct
9 Correct 1 ms 2512 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2512 KB Output is correct
12 Correct 1 ms 2516 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 208 ms 27032 KB Output is correct
17 Correct 202 ms 26548 KB Output is correct
18 Correct 208 ms 26548 KB Output is correct
19 Correct 163 ms 27124 KB Output is correct
20 Correct 190 ms 27152 KB Output is correct
21 Correct 225 ms 26408 KB Output is correct
22 Correct 209 ms 26536 KB Output is correct
23 Correct 175 ms 27780 KB Output is correct
24 Correct 215 ms 29332 KB Output is correct
25 Correct 157 ms 26544 KB Output is correct
26 Correct 221 ms 28208 KB Output is correct
27 Correct 165 ms 26816 KB Output is correct
28 Correct 199 ms 27000 KB Output is correct
29 Correct 221 ms 28560 KB Output is correct
30 Correct 159 ms 27172 KB Output is correct
31 Correct 216 ms 28632 KB Output is correct
32 Correct 174 ms 27336 KB Output is correct
33 Correct 209 ms 27048 KB Output is correct
34 Correct 169 ms 26792 KB Output is correct
35 Correct 214 ms 28008 KB Output is correct
36 Correct 1 ms 2392 KB Output is correct
37 Correct 7 ms 5080 KB Output is correct
38 Correct 13 ms 5240 KB Output is correct
39 Correct 8 ms 5092 KB Output is correct
40 Correct 9 ms 5076 KB Output is correct
41 Correct 8 ms 5208 KB Output is correct
42 Correct 10 ms 5092 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 1 ms 2520 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 8 ms 5080 KB Output is correct
50 Correct 6 ms 5076 KB Output is correct
51 Correct 7 ms 5080 KB Output is correct
52 Correct 7 ms 5116 KB Output is correct
53 Correct 8 ms 5076 KB Output is correct
54 Correct 6 ms 5080 KB Output is correct
55 Correct 9 ms 5168 KB Output is correct
56 Correct 9 ms 5320 KB Output is correct
57 Correct 6 ms 5076 KB Output is correct
58 Correct 7 ms 5080 KB Output is correct
59 Correct 8 ms 5080 KB Output is correct
60 Correct 9 ms 5092 KB Output is correct
61 Correct 1 ms 2520 KB Output is correct
62 Correct 204 ms 22892 KB Output is correct
63 Correct 209 ms 23984 KB Output is correct
64 Correct 211 ms 23212 KB Output is correct
65 Correct 204 ms 22812 KB Output is correct
66 Correct 205 ms 23720 KB Output is correct
67 Correct 206 ms 22844 KB Output is correct
68 Correct 1 ms 2396 KB Output is correct
69 Correct 1 ms 2396 KB Output is correct
70 Correct 1 ms 2392 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 1 ms 2396 KB Output is correct
73 Correct 1 ms 2396 KB Output is correct
74 Correct 180 ms 23628 KB Output is correct
75 Correct 185 ms 23472 KB Output is correct
76 Correct 216 ms 23196 KB Output is correct
77 Correct 172 ms 22860 KB Output is correct
78 Correct 203 ms 23976 KB Output is correct
79 Correct 169 ms 23496 KB Output is correct
80 Correct 190 ms 22188 KB Output is correct
81 Correct 177 ms 23984 KB Output is correct
82 Correct 153 ms 24668 KB Output is correct
83 Correct 150 ms 24556 KB Output is correct
84 Correct 185 ms 23320 KB Output is correct
85 Correct 198 ms 23756 KB Output is correct
86 Correct 171 ms 22700 KB Output is correct
87 Correct 198 ms 23364 KB Output is correct
88 Correct 1 ms 2396 KB Output is correct
89 Correct 1 ms 2396 KB Output is correct
90 Correct 1 ms 2408 KB Output is correct
91 Correct 1 ms 2396 KB Output is correct
92 Correct 1 ms 2396 KB Output is correct
93 Correct 1 ms 2396 KB Output is correct
94 Correct 1 ms 2396 KB Output is correct
95 Correct 1 ms 2392 KB Output is correct
96 Correct 1 ms 2396 KB Output is correct
97 Correct 1 ms 2512 KB Output is correct
98 Correct 1 ms 2392 KB Output is correct
99 Correct 1 ms 2508 KB Output is correct
100 Correct 1 ms 2512 KB Output is correct
101 Correct 1 ms 2392 KB Output is correct
102 Correct 1 ms 2392 KB Output is correct
103 Correct 1 ms 2392 KB Output is correct
104 Correct 8 ms 5336 KB Output is correct
105 Correct 11 ms 5332 KB Output is correct
106 Correct 11 ms 5332 KB Output is correct
107 Correct 11 ms 5336 KB Output is correct
108 Correct 11 ms 5336 KB Output is correct
109 Correct 11 ms 5336 KB Output is correct
110 Correct 1 ms 2404 KB Output is correct
111 Correct 1 ms 2404 KB Output is correct
112 Correct 1 ms 2404 KB Output is correct
113 Correct 1 ms 2404 KB Output is correct
114 Correct 1 ms 2516 KB Output is correct
115 Correct 1 ms 2408 KB Output is correct
116 Correct 11 ms 5216 KB Output is correct
117 Correct 11 ms 5348 KB Output is correct
118 Correct 13 ms 5604 KB Output is correct
119 Correct 12 ms 5348 KB Output is correct
120 Correct 11 ms 5348 KB Output is correct
121 Correct 7 ms 5332 KB Output is correct
122 Correct 7 ms 5336 KB Output is correct
123 Correct 7 ms 5336 KB Output is correct
124 Correct 7 ms 5336 KB Output is correct
125 Correct 10 ms 5336 KB Output is correct
126 Correct 8 ms 5336 KB Output is correct
127 Correct 8 ms 5336 KB Output is correct
128 Correct 1 ms 2392 KB Output is correct
129 Correct 250 ms 26788 KB Output is correct
130 Correct 506 ms 57280 KB Output is correct
131 Correct 505 ms 58856 KB Output is correct
132 Correct 497 ms 56960 KB Output is correct
133 Correct 496 ms 57368 KB Output is correct
134 Correct 512 ms 58780 KB Output is correct
135 Correct 1 ms 2396 KB Output is correct
136 Correct 1 ms 2396 KB Output is correct
137 Correct 1 ms 2396 KB Output is correct
138 Correct 1 ms 2396 KB Output is correct
139 Correct 1 ms 2396 KB Output is correct
140 Correct 1 ms 2396 KB Output is correct
141 Correct 470 ms 59964 KB Output is correct
142 Correct 493 ms 57756 KB Output is correct
143 Correct 506 ms 58308 KB Output is correct
144 Correct 488 ms 59396 KB Output is correct
145 Correct 471 ms 58860 KB Output is correct
146 Correct 437 ms 57056 KB Output is correct
147 Correct 444 ms 56896 KB Output is correct
148 Correct 430 ms 57228 KB Output is correct
149 Correct 260 ms 27296 KB Output is correct
150 Correct 168 ms 27720 KB Output is correct
151 Correct 168 ms 26872 KB Output is correct
152 Correct 266 ms 27540 KB Output is correct
153 Correct 212 ms 26276 KB Output is correct
154 Correct 236 ms 27032 KB Output is correct
155 Correct 260 ms 27404 KB Output is correct