답안 #709701

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709701 2023-03-14T08:11:19 Z awu Fuel Station (NOI20_fuelstation) C++14
100 / 100
170 ms 35524 KB
#include <bits/extc++.h>
using namespace std;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")

#define int long long
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) do{auto y = x; cout << #x << " = " << y << endl;}while(0)
// #define endl "\n"
#define unordered_map __gnu_pbds::gp_hash_table
using pii = pair<int, int>;

const int inf = 1ll << 60;
const int MOD = 1e9 + 7;

struct fuel {
  int x, a, b;
};
bool operator>(fuel a, fuel b) {
  return a.b > b.b;
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, d; cin >> n >> d;
  vector<fuel> fs(n);
  for(int i = 0; i < n; i++) {
    cin >> fs[i].x >> fs[i].a >> fs[i].b;
  }
  fs.push_back({d, 0, 0});
  sort(all(fs), [](fuel a, fuel b) {
    return a.x < b.x;
  });
  priority_queue<fuel, vector<fuel>, greater<fuel>> pq;
  int sf = 0, cf = 0, pos = 0;
  for(auto f : fs) {
    cf -= f.x - pos;
    pos = f.x;
    if(cf < 0) {
      sf -= cf;
      cf = 0;
      while(pq.size() && pq.top().b < sf) {
        sf += pq.top().a;
        pq.pop();
      }
    }
    if(sf <= f.b) {
      cf += f.a;
      pq.push(f);
    }
  }
  cout << sf << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 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 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 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 143 ms 26692 KB Output is correct
2 Correct 136 ms 26692 KB Output is correct
3 Correct 132 ms 26696 KB Output is correct
4 Correct 142 ms 26680 KB Output is correct
5 Correct 123 ms 26744 KB Output is correct
6 Correct 125 ms 26676 KB Output is correct
7 Correct 128 ms 26692 KB Output is correct
8 Correct 132 ms 26684 KB Output is correct
9 Correct 164 ms 26712 KB Output is correct
10 Correct 127 ms 26684 KB Output is correct
11 Correct 126 ms 26688 KB Output is correct
12 Correct 118 ms 26680 KB Output is correct
13 Correct 133 ms 26696 KB Output is correct
14 Correct 125 ms 26680 KB Output is correct
15 Correct 121 ms 26676 KB Output is correct
16 Correct 130 ms 26724 KB Output is correct
17 Correct 145 ms 26692 KB Output is correct
18 Correct 126 ms 26692 KB Output is correct
19 Correct 119 ms 26696 KB Output is correct
20 Correct 124 ms 26680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 4 ms 1128 KB Output is correct
3 Correct 4 ms 1128 KB Output is correct
4 Correct 4 ms 1128 KB Output is correct
5 Correct 4 ms 1128 KB Output is correct
6 Correct 4 ms 1128 KB Output is correct
7 Correct 4 ms 1128 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 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 212 KB Output is correct
14 Correct 4 ms 852 KB Output is correct
15 Correct 4 ms 936 KB Output is correct
16 Correct 5 ms 844 KB Output is correct
17 Correct 4 ms 844 KB Output is correct
18 Correct 3 ms 932 KB Output is correct
19 Correct 4 ms 1256 KB Output is correct
20 Correct 4 ms 1256 KB Output is correct
21 Correct 5 ms 1300 KB Output is correct
22 Correct 4 ms 1256 KB Output is correct
23 Correct 4 ms 1240 KB Output is correct
24 Correct 4 ms 1212 KB Output is correct
25 Correct 4 ms 1228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 4 ms 1128 KB Output is correct
3 Correct 4 ms 1128 KB Output is correct
4 Correct 4 ms 1128 KB Output is correct
5 Correct 4 ms 1128 KB Output is correct
6 Correct 4 ms 1128 KB Output is correct
7 Correct 4 ms 1128 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 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 212 KB Output is correct
14 Correct 4 ms 852 KB Output is correct
15 Correct 4 ms 936 KB Output is correct
16 Correct 5 ms 844 KB Output is correct
17 Correct 4 ms 844 KB Output is correct
18 Correct 3 ms 932 KB Output is correct
19 Correct 4 ms 1256 KB Output is correct
20 Correct 4 ms 1256 KB Output is correct
21 Correct 5 ms 1300 KB Output is correct
22 Correct 4 ms 1256 KB Output is correct
23 Correct 4 ms 1240 KB Output is correct
24 Correct 4 ms 1212 KB Output is correct
25 Correct 4 ms 1228 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 105 ms 30984 KB Output is correct
28 Correct 117 ms 30772 KB Output is correct
29 Correct 101 ms 30512 KB Output is correct
30 Correct 102 ms 30516 KB Output is correct
31 Correct 108 ms 31020 KB Output is correct
32 Correct 107 ms 30792 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 0 ms 320 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 90 ms 18736 KB Output is correct
40 Correct 96 ms 18732 KB Output is correct
41 Correct 88 ms 18736 KB Output is correct
42 Correct 84 ms 18740 KB Output is correct
43 Correct 98 ms 18616 KB Output is correct
44 Correct 93 ms 18232 KB Output is correct
45 Correct 87 ms 17844 KB Output is correct
46 Correct 100 ms 30984 KB Output is correct
47 Correct 131 ms 32560 KB Output is correct
48 Correct 118 ms 32456 KB Output is correct
49 Correct 98 ms 30380 KB Output is correct
50 Correct 98 ms 30776 KB Output is correct
51 Correct 100 ms 30680 KB Output is correct
52 Correct 97 ms 30380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 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 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 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 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 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 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 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 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 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 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 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 4 ms 1128 KB Output is correct
18 Correct 4 ms 1128 KB Output is correct
19 Correct 4 ms 1128 KB Output is correct
20 Correct 4 ms 1128 KB Output is correct
21 Correct 4 ms 1128 KB Output is correct
22 Correct 4 ms 1128 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 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 4 ms 852 KB Output is correct
30 Correct 4 ms 936 KB Output is correct
31 Correct 5 ms 844 KB Output is correct
32 Correct 4 ms 844 KB Output is correct
33 Correct 3 ms 932 KB Output is correct
34 Correct 4 ms 1256 KB Output is correct
35 Correct 4 ms 1256 KB Output is correct
36 Correct 5 ms 1300 KB Output is correct
37 Correct 4 ms 1256 KB Output is correct
38 Correct 4 ms 1240 KB Output is correct
39 Correct 4 ms 1212 KB Output is correct
40 Correct 4 ms 1228 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 5 ms 1256 KB Output is correct
43 Correct 6 ms 1384 KB Output is correct
44 Correct 5 ms 1396 KB Output is correct
45 Correct 5 ms 1384 KB Output is correct
46 Correct 5 ms 1384 KB Output is correct
47 Correct 5 ms 1384 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 320 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 320 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 4 ms 988 KB Output is correct
55 Correct 6 ms 1008 KB Output is correct
56 Correct 4 ms 980 KB Output is correct
57 Correct 5 ms 980 KB Output is correct
58 Correct 4 ms 988 KB Output is correct
59 Correct 4 ms 972 KB Output is correct
60 Correct 5 ms 1384 KB Output is correct
61 Correct 5 ms 1380 KB Output is correct
62 Correct 5 ms 1388 KB Output is correct
63 Correct 5 ms 1128 KB Output is correct
64 Correct 5 ms 1384 KB Output is correct
65 Correct 4 ms 1312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 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 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 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 143 ms 26692 KB Output is correct
17 Correct 136 ms 26692 KB Output is correct
18 Correct 132 ms 26696 KB Output is correct
19 Correct 142 ms 26680 KB Output is correct
20 Correct 123 ms 26744 KB Output is correct
21 Correct 125 ms 26676 KB Output is correct
22 Correct 128 ms 26692 KB Output is correct
23 Correct 132 ms 26684 KB Output is correct
24 Correct 164 ms 26712 KB Output is correct
25 Correct 127 ms 26684 KB Output is correct
26 Correct 126 ms 26688 KB Output is correct
27 Correct 118 ms 26680 KB Output is correct
28 Correct 133 ms 26696 KB Output is correct
29 Correct 125 ms 26680 KB Output is correct
30 Correct 121 ms 26676 KB Output is correct
31 Correct 130 ms 26724 KB Output is correct
32 Correct 145 ms 26692 KB Output is correct
33 Correct 126 ms 26692 KB Output is correct
34 Correct 119 ms 26696 KB Output is correct
35 Correct 124 ms 26680 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 4 ms 1128 KB Output is correct
38 Correct 4 ms 1128 KB Output is correct
39 Correct 4 ms 1128 KB Output is correct
40 Correct 4 ms 1128 KB Output is correct
41 Correct 4 ms 1128 KB Output is correct
42 Correct 4 ms 1128 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 0 ms 212 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 212 KB Output is correct
49 Correct 4 ms 852 KB Output is correct
50 Correct 4 ms 936 KB Output is correct
51 Correct 5 ms 844 KB Output is correct
52 Correct 4 ms 844 KB Output is correct
53 Correct 3 ms 932 KB Output is correct
54 Correct 4 ms 1256 KB Output is correct
55 Correct 4 ms 1256 KB Output is correct
56 Correct 5 ms 1300 KB Output is correct
57 Correct 4 ms 1256 KB Output is correct
58 Correct 4 ms 1240 KB Output is correct
59 Correct 4 ms 1212 KB Output is correct
60 Correct 4 ms 1228 KB Output is correct
61 Correct 0 ms 212 KB Output is correct
62 Correct 105 ms 30984 KB Output is correct
63 Correct 117 ms 30772 KB Output is correct
64 Correct 101 ms 30512 KB Output is correct
65 Correct 102 ms 30516 KB Output is correct
66 Correct 108 ms 31020 KB Output is correct
67 Correct 107 ms 30792 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 0 ms 320 KB Output is correct
70 Correct 1 ms 212 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 1 ms 212 KB Output is correct
73 Correct 1 ms 212 KB Output is correct
74 Correct 90 ms 18736 KB Output is correct
75 Correct 96 ms 18732 KB Output is correct
76 Correct 88 ms 18736 KB Output is correct
77 Correct 84 ms 18740 KB Output is correct
78 Correct 98 ms 18616 KB Output is correct
79 Correct 93 ms 18232 KB Output is correct
80 Correct 87 ms 17844 KB Output is correct
81 Correct 100 ms 30984 KB Output is correct
82 Correct 131 ms 32560 KB Output is correct
83 Correct 118 ms 32456 KB Output is correct
84 Correct 98 ms 30380 KB Output is correct
85 Correct 98 ms 30776 KB Output is correct
86 Correct 100 ms 30680 KB Output is correct
87 Correct 97 ms 30380 KB Output is correct
88 Correct 1 ms 212 KB Output is correct
89 Correct 1 ms 212 KB Output is correct
90 Correct 1 ms 212 KB Output is correct
91 Correct 0 ms 212 KB Output is correct
92 Correct 0 ms 212 KB Output is correct
93 Correct 0 ms 212 KB Output is correct
94 Correct 0 ms 212 KB Output is correct
95 Correct 1 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 1 ms 212 KB Output is correct
103 Correct 0 ms 212 KB Output is correct
104 Correct 5 ms 1256 KB Output is correct
105 Correct 6 ms 1384 KB Output is correct
106 Correct 5 ms 1396 KB Output is correct
107 Correct 5 ms 1384 KB Output is correct
108 Correct 5 ms 1384 KB Output is correct
109 Correct 5 ms 1384 KB Output is correct
110 Correct 1 ms 212 KB Output is correct
111 Correct 1 ms 320 KB Output is correct
112 Correct 0 ms 212 KB Output is correct
113 Correct 1 ms 212 KB Output is correct
114 Correct 1 ms 320 KB Output is correct
115 Correct 0 ms 212 KB Output is correct
116 Correct 4 ms 988 KB Output is correct
117 Correct 6 ms 1008 KB Output is correct
118 Correct 4 ms 980 KB Output is correct
119 Correct 5 ms 980 KB Output is correct
120 Correct 4 ms 988 KB Output is correct
121 Correct 4 ms 972 KB Output is correct
122 Correct 5 ms 1384 KB Output is correct
123 Correct 5 ms 1380 KB Output is correct
124 Correct 5 ms 1388 KB Output is correct
125 Correct 5 ms 1128 KB Output is correct
126 Correct 5 ms 1384 KB Output is correct
127 Correct 4 ms 1312 KB Output is correct
128 Correct 0 ms 212 KB Output is correct
129 Correct 152 ms 33968 KB Output is correct
130 Correct 160 ms 34724 KB Output is correct
131 Correct 136 ms 35376 KB Output is correct
132 Correct 137 ms 34752 KB Output is correct
133 Correct 153 ms 34808 KB Output is correct
134 Correct 156 ms 35524 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 0 ms 212 KB Output is correct
139 Correct 0 ms 320 KB Output is correct
140 Correct 1 ms 212 KB Output is correct
141 Correct 129 ms 23108 KB Output is correct
142 Correct 133 ms 22744 KB Output is correct
143 Correct 137 ms 23100 KB Output is correct
144 Correct 133 ms 23108 KB Output is correct
145 Correct 124 ms 23104 KB Output is correct
146 Correct 163 ms 24988 KB Output is correct
147 Correct 166 ms 25784 KB Output is correct
148 Correct 170 ms 24612 KB Output is correct
149 Correct 139 ms 34744 KB Output is correct
150 Correct 133 ms 35000 KB Output is correct
151 Correct 128 ms 35124 KB Output is correct
152 Correct 140 ms 34744 KB Output is correct
153 Correct 133 ms 34744 KB Output is correct
154 Correct 125 ms 34760 KB Output is correct
155 Correct 132 ms 34736 KB Output is correct