답안 #676488

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
676488 2022-12-31T03:37:45 Z penguin133 Fuel Station (NOI20_fuelstation) C++17
100 / 100
1239 ms 72864 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
pair<int, pii> A[300005];
pii B[300005];
int exis[300005];
struct node{
	int s,e,m,val, lazy;
	node *l, *r;
	node(int _s, int _e){
		s = _s, e = _e, m = (s + e)/2;
		val = 0;
		lazy = 0;
		if(s != e){
			l = new node(s, m);
			r=  new node(m+1, e);
		} 
	}
	void propo(){
		if(lazy){
			val += lazy;
			if(s != e){
				l->lazy += lazy;
				r->lazy += lazy;
			}
			lazy = 0;
		}
	}
	void update(int a, int b, int c){
		if(a == s && b == e)lazy += c;
		else{
			if(b <= m)l->update(a,b,c);
			else if(a > m)r->update(a,b,c);
			else l->update(a,m,c), r->update(m+1,b,c);
			l->propo(), r->propo();
			val = min(l->val, r->val);
		}
	}
	int query(int p){
		propo();
		if(s == e)return val;
		if(p <= m)return l->query(p);
		else return r->query(p);
	}
}*root;
main(){
	int n,d;cin >> n >> d;
	root = new node(0, n+ 5);
	for(int i=1;i<=n;i++){
		cin >> A[i].first >> A[i].second.first >> A[i].second.second;
	}
	sort(A+1, A+n+1);
	A[n+1] = {d,{0,0}};
	for(int i=1;i<=n;i++)B[i] = {A[i].second.second, i};
	sort(B+1, B+n+1);
	int in = n ;
	exis[0] = exis[n+1] = true;
	multiset<int>s;
	s.insert(0);
	s.insert(n+1);
	root->update(0,0,0);
	root->update(n+1,n+1,-d);
	int cnt = d;
	while(in >= 1){
		int x = B[in].first;
		while(B[in].first == x){
			int y = B[in].second;
			multiset<int> :: iterator it = s.upper_bound(y);
			it--;
			int temp = root->query(*it);
			root->update(y,y,temp + A[*it].first - A[y].first + A[*it].second.first);
			root->update(y+1,n+1,A[y].second.first); 
			s.insert(y);
			in--;
		}
		root->propo();
		int mini = root->val;
		mini = -mini;
		if(mini <= x)cnt = min(cnt, mini);
	}
	cout << cnt;
}

Compilation message

FuelStation.cpp:47:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   47 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 300 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 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 656 ms 72108 KB Output is correct
2 Correct 660 ms 72028 KB Output is correct
3 Correct 658 ms 72044 KB Output is correct
4 Correct 656 ms 72076 KB Output is correct
5 Correct 679 ms 72652 KB Output is correct
6 Correct 637 ms 71460 KB Output is correct
7 Correct 648 ms 71440 KB Output is correct
8 Correct 676 ms 72036 KB Output is correct
9 Correct 698 ms 72748 KB Output is correct
10 Correct 661 ms 71452 KB Output is correct
11 Correct 626 ms 71496 KB Output is correct
12 Correct 672 ms 72016 KB Output is correct
13 Correct 663 ms 71480 KB Output is correct
14 Correct 692 ms 72188 KB Output is correct
15 Correct 692 ms 72068 KB Output is correct
16 Correct 687 ms 72864 KB Output is correct
17 Correct 685 ms 72804 KB Output is correct
18 Correct 680 ms 72068 KB Output is correct
19 Correct 676 ms 72148 KB Output is correct
20 Correct 668 ms 72088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 24 ms 2492 KB Output is correct
3 Correct 18 ms 2488 KB Output is correct
4 Correct 19 ms 2508 KB Output is correct
5 Correct 18 ms 2620 KB Output is correct
6 Correct 18 ms 2516 KB Output is correct
7 Correct 20 ms 2564 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 20 ms 2620 KB Output is correct
15 Correct 23 ms 2512 KB Output is correct
16 Correct 21 ms 2512 KB Output is correct
17 Correct 22 ms 2456 KB Output is correct
18 Correct 21 ms 2468 KB Output is correct
19 Correct 23 ms 2496 KB Output is correct
20 Correct 20 ms 2552 KB Output is correct
21 Correct 20 ms 2624 KB Output is correct
22 Correct 20 ms 2496 KB Output is correct
23 Correct 18 ms 2440 KB Output is correct
24 Correct 21 ms 2548 KB Output is correct
25 Correct 21 ms 2500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 24 ms 2492 KB Output is correct
3 Correct 18 ms 2488 KB Output is correct
4 Correct 19 ms 2508 KB Output is correct
5 Correct 18 ms 2620 KB Output is correct
6 Correct 18 ms 2516 KB Output is correct
7 Correct 20 ms 2564 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 20 ms 2620 KB Output is correct
15 Correct 23 ms 2512 KB Output is correct
16 Correct 21 ms 2512 KB Output is correct
17 Correct 22 ms 2456 KB Output is correct
18 Correct 21 ms 2468 KB Output is correct
19 Correct 23 ms 2496 KB Output is correct
20 Correct 20 ms 2552 KB Output is correct
21 Correct 20 ms 2624 KB Output is correct
22 Correct 20 ms 2496 KB Output is correct
23 Correct 18 ms 2440 KB Output is correct
24 Correct 21 ms 2548 KB Output is correct
25 Correct 21 ms 2500 KB Output is correct
26 Correct 1 ms 308 KB Output is correct
27 Correct 994 ms 67980 KB Output is correct
28 Correct 990 ms 67756 KB Output is correct
29 Correct 1022 ms 67412 KB Output is correct
30 Correct 986 ms 67388 KB Output is correct
31 Correct 1034 ms 68068 KB Output is correct
32 Correct 1016 ms 67676 KB Output is correct
33 Correct 1 ms 308 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1012 ms 68056 KB Output is correct
40 Correct 1092 ms 68032 KB Output is correct
41 Correct 1081 ms 68020 KB Output is correct
42 Correct 1102 ms 68028 KB Output is correct
43 Correct 1040 ms 67972 KB Output is correct
44 Correct 785 ms 67524 KB Output is correct
45 Correct 577 ms 67044 KB Output is correct
46 Correct 1112 ms 67984 KB Output is correct
47 Correct 668 ms 69508 KB Output is correct
48 Correct 657 ms 69492 KB Output is correct
49 Correct 1075 ms 67288 KB Output is correct
50 Correct 1048 ms 67712 KB Output is correct
51 Correct 1057 ms 67716 KB Output is correct
52 Correct 1081 ms 67348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 300 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 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 312 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 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 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 304 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 300 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 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 312 KB Output is correct
17 Correct 24 ms 2492 KB Output is correct
18 Correct 18 ms 2488 KB Output is correct
19 Correct 19 ms 2508 KB Output is correct
20 Correct 18 ms 2620 KB Output is correct
21 Correct 18 ms 2516 KB Output is correct
22 Correct 20 ms 2564 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 312 KB Output is correct
26 Correct 1 ms 304 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 312 KB Output is correct
29 Correct 20 ms 2620 KB Output is correct
30 Correct 23 ms 2512 KB Output is correct
31 Correct 21 ms 2512 KB Output is correct
32 Correct 22 ms 2456 KB Output is correct
33 Correct 21 ms 2468 KB Output is correct
34 Correct 23 ms 2496 KB Output is correct
35 Correct 20 ms 2552 KB Output is correct
36 Correct 20 ms 2624 KB Output is correct
37 Correct 20 ms 2496 KB Output is correct
38 Correct 18 ms 2440 KB Output is correct
39 Correct 21 ms 2548 KB Output is correct
40 Correct 21 ms 2500 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 26 ms 2584 KB Output is correct
43 Correct 29 ms 2672 KB Output is correct
44 Correct 24 ms 2664 KB Output is correct
45 Correct 30 ms 2684 KB Output is correct
46 Correct 28 ms 2636 KB Output is correct
47 Correct 28 ms 2696 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 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 300 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 27 ms 2636 KB Output is correct
55 Correct 23 ms 2644 KB Output is correct
56 Correct 23 ms 2632 KB Output is correct
57 Correct 25 ms 2628 KB Output is correct
58 Correct 24 ms 2628 KB Output is correct
59 Correct 27 ms 2632 KB Output is correct
60 Correct 22 ms 2708 KB Output is correct
61 Correct 21 ms 2684 KB Output is correct
62 Correct 30 ms 2652 KB Output is correct
63 Correct 28 ms 2604 KB Output is correct
64 Correct 24 ms 2612 KB Output is correct
65 Correct 24 ms 2548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 300 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 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 656 ms 72108 KB Output is correct
17 Correct 660 ms 72028 KB Output is correct
18 Correct 658 ms 72044 KB Output is correct
19 Correct 656 ms 72076 KB Output is correct
20 Correct 679 ms 72652 KB Output is correct
21 Correct 637 ms 71460 KB Output is correct
22 Correct 648 ms 71440 KB Output is correct
23 Correct 676 ms 72036 KB Output is correct
24 Correct 698 ms 72748 KB Output is correct
25 Correct 661 ms 71452 KB Output is correct
26 Correct 626 ms 71496 KB Output is correct
27 Correct 672 ms 72016 KB Output is correct
28 Correct 663 ms 71480 KB Output is correct
29 Correct 692 ms 72188 KB Output is correct
30 Correct 692 ms 72068 KB Output is correct
31 Correct 687 ms 72864 KB Output is correct
32 Correct 685 ms 72804 KB Output is correct
33 Correct 680 ms 72068 KB Output is correct
34 Correct 676 ms 72148 KB Output is correct
35 Correct 668 ms 72088 KB Output is correct
36 Correct 1 ms 312 KB Output is correct
37 Correct 24 ms 2492 KB Output is correct
38 Correct 18 ms 2488 KB Output is correct
39 Correct 19 ms 2508 KB Output is correct
40 Correct 18 ms 2620 KB Output is correct
41 Correct 18 ms 2516 KB Output is correct
42 Correct 20 ms 2564 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 312 KB Output is correct
46 Correct 1 ms 304 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 312 KB Output is correct
49 Correct 20 ms 2620 KB Output is correct
50 Correct 23 ms 2512 KB Output is correct
51 Correct 21 ms 2512 KB Output is correct
52 Correct 22 ms 2456 KB Output is correct
53 Correct 21 ms 2468 KB Output is correct
54 Correct 23 ms 2496 KB Output is correct
55 Correct 20 ms 2552 KB Output is correct
56 Correct 20 ms 2624 KB Output is correct
57 Correct 20 ms 2496 KB Output is correct
58 Correct 18 ms 2440 KB Output is correct
59 Correct 21 ms 2548 KB Output is correct
60 Correct 21 ms 2500 KB Output is correct
61 Correct 1 ms 308 KB Output is correct
62 Correct 994 ms 67980 KB Output is correct
63 Correct 990 ms 67756 KB Output is correct
64 Correct 1022 ms 67412 KB Output is correct
65 Correct 986 ms 67388 KB Output is correct
66 Correct 1034 ms 68068 KB Output is correct
67 Correct 1016 ms 67676 KB Output is correct
68 Correct 1 ms 308 KB Output is correct
69 Correct 0 ms 212 KB Output is correct
70 Correct 1 ms 212 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 0 ms 212 KB Output is correct
73 Correct 1 ms 212 KB Output is correct
74 Correct 1012 ms 68056 KB Output is correct
75 Correct 1092 ms 68032 KB Output is correct
76 Correct 1081 ms 68020 KB Output is correct
77 Correct 1102 ms 68028 KB Output is correct
78 Correct 1040 ms 67972 KB Output is correct
79 Correct 785 ms 67524 KB Output is correct
80 Correct 577 ms 67044 KB Output is correct
81 Correct 1112 ms 67984 KB Output is correct
82 Correct 668 ms 69508 KB Output is correct
83 Correct 657 ms 69492 KB Output is correct
84 Correct 1075 ms 67288 KB Output is correct
85 Correct 1048 ms 67712 KB Output is correct
86 Correct 1057 ms 67716 KB Output is correct
87 Correct 1081 ms 67348 KB Output is correct
88 Correct 1 ms 308 KB Output is correct
89 Correct 1 ms 212 KB Output is correct
90 Correct 1 ms 384 KB Output is correct
91 Correct 1 ms 256 KB Output is correct
92 Correct 1 ms 212 KB Output is correct
93 Correct 1 ms 312 KB Output is correct
94 Correct 1 ms 212 KB Output is correct
95 Correct 1 ms 212 KB Output is correct
96 Correct 1 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 1 ms 212 KB Output is correct
100 Correct 1 ms 212 KB Output is correct
101 Correct 1 ms 304 KB Output is correct
102 Correct 1 ms 212 KB Output is correct
103 Correct 1 ms 212 KB Output is correct
104 Correct 26 ms 2584 KB Output is correct
105 Correct 29 ms 2672 KB Output is correct
106 Correct 24 ms 2664 KB Output is correct
107 Correct 30 ms 2684 KB Output is correct
108 Correct 28 ms 2636 KB Output is correct
109 Correct 28 ms 2696 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 212 KB Output is correct
113 Correct 1 ms 212 KB Output is correct
114 Correct 1 ms 300 KB Output is correct
115 Correct 1 ms 212 KB Output is correct
116 Correct 27 ms 2636 KB Output is correct
117 Correct 23 ms 2644 KB Output is correct
118 Correct 23 ms 2632 KB Output is correct
119 Correct 25 ms 2628 KB Output is correct
120 Correct 24 ms 2628 KB Output is correct
121 Correct 27 ms 2632 KB Output is correct
122 Correct 22 ms 2708 KB Output is correct
123 Correct 21 ms 2684 KB Output is correct
124 Correct 30 ms 2652 KB Output is correct
125 Correct 28 ms 2604 KB Output is correct
126 Correct 24 ms 2612 KB Output is correct
127 Correct 24 ms 2548 KB Output is correct
128 Correct 1 ms 212 KB Output is correct
129 Correct 1239 ms 71128 KB Output is correct
130 Correct 1185 ms 71744 KB Output is correct
131 Correct 1140 ms 72408 KB Output is correct
132 Correct 1136 ms 71724 KB Output is correct
133 Correct 1188 ms 71776 KB Output is correct
134 Correct 1181 ms 72408 KB Output is correct
135 Correct 1 ms 212 KB Output is correct
136 Correct 1 ms 212 KB Output is correct
137 Correct 1 ms 212 KB Output is correct
138 Correct 1 ms 312 KB Output is correct
139 Correct 1 ms 304 KB Output is correct
140 Correct 1 ms 304 KB Output is correct
141 Correct 1217 ms 72424 KB Output is correct
142 Correct 1126 ms 72124 KB Output is correct
143 Correct 1179 ms 72460 KB Output is correct
144 Correct 1146 ms 72324 KB Output is correct
145 Correct 1212 ms 72356 KB Output is correct
146 Correct 977 ms 70684 KB Output is correct
147 Correct 1030 ms 71456 KB Output is correct
148 Correct 1054 ms 70948 KB Output is correct
149 Correct 1170 ms 71696 KB Output is correct
150 Correct 691 ms 71896 KB Output is correct
151 Correct 673 ms 72008 KB Output is correct
152 Correct 1044 ms 71784 KB Output is correct
153 Correct 1164 ms 71744 KB Output is correct
154 Correct 1069 ms 71672 KB Output is correct
155 Correct 1159 ms 71680 KB Output is correct