답안 #709693

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709693 2023-03-14T07:58:32 Z awu Fuel Station (NOI20_fuelstation) C++14
39 / 100
147 ms 35756 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.x < b.x;
}

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));
  auto bcmp = [](fuel a, fuel b) {
    return a.b < b.b;
  };
  priority_queue<fuel, vector<fuel>, decltype(bcmp)> pq(bcmp);
  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 1 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 324 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 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 147 ms 35372 KB Output is correct
2 Correct 147 ms 35124 KB Output is correct
3 Correct 135 ms 34996 KB Output is correct
4 Correct 134 ms 35140 KB Output is correct
5 Correct 134 ms 35672 KB Output is correct
6 Correct 146 ms 34504 KB Output is correct
7 Correct 140 ms 34612 KB Output is correct
8 Correct 134 ms 34984 KB Output is correct
9 Correct 135 ms 35632 KB Output is correct
10 Correct 129 ms 34484 KB Output is correct
11 Correct 144 ms 34504 KB Output is correct
12 Correct 139 ms 35120 KB Output is correct
13 Correct 139 ms 34480 KB Output is correct
14 Correct 142 ms 35128 KB Output is correct
15 Correct 135 ms 35124 KB Output is correct
16 Correct 141 ms 35756 KB Output is correct
17 Correct 141 ms 35636 KB Output is correct
18 Correct 135 ms 35112 KB Output is correct
19 Correct 137 ms 35140 KB Output is correct
20 Correct 147 ms 35108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 4 ms 1212 KB Output is correct
3 Correct 5 ms 1244 KB Output is correct
4 Correct 4 ms 1256 KB Output is correct
5 Correct 4 ms 1228 KB Output is correct
6 Correct 5 ms 1256 KB Output is correct
7 Correct 4 ms 1248 KB Output is correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 4 ms 1212 KB Output is correct
3 Correct 5 ms 1244 KB Output is correct
4 Correct 4 ms 1256 KB Output is correct
5 Correct 4 ms 1228 KB Output is correct
6 Correct 5 ms 1256 KB Output is correct
7 Correct 4 ms 1248 KB Output is correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 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 324 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 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 0 ms 324 KB Output is correct
19 Correct 1 ms 320 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 0 ms 212 KB Output is correct
24 Correct 0 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 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 316 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 1 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 324 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 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 212 KB Output is correct
17 Correct 4 ms 1212 KB Output is correct
18 Correct 5 ms 1244 KB Output is correct
19 Correct 4 ms 1256 KB Output is correct
20 Correct 4 ms 1228 KB Output is correct
21 Correct 5 ms 1256 KB Output is correct
22 Correct 4 ms 1248 KB Output is correct
23 Incorrect 0 ms 212 KB Output isn't correct
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 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 324 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 147 ms 35372 KB Output is correct
17 Correct 147 ms 35124 KB Output is correct
18 Correct 135 ms 34996 KB Output is correct
19 Correct 134 ms 35140 KB Output is correct
20 Correct 134 ms 35672 KB Output is correct
21 Correct 146 ms 34504 KB Output is correct
22 Correct 140 ms 34612 KB Output is correct
23 Correct 134 ms 34984 KB Output is correct
24 Correct 135 ms 35632 KB Output is correct
25 Correct 129 ms 34484 KB Output is correct
26 Correct 144 ms 34504 KB Output is correct
27 Correct 139 ms 35120 KB Output is correct
28 Correct 139 ms 34480 KB Output is correct
29 Correct 142 ms 35128 KB Output is correct
30 Correct 135 ms 35124 KB Output is correct
31 Correct 141 ms 35756 KB Output is correct
32 Correct 141 ms 35636 KB Output is correct
33 Correct 135 ms 35112 KB Output is correct
34 Correct 137 ms 35140 KB Output is correct
35 Correct 147 ms 35108 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 4 ms 1212 KB Output is correct
38 Correct 5 ms 1244 KB Output is correct
39 Correct 4 ms 1256 KB Output is correct
40 Correct 4 ms 1228 KB Output is correct
41 Correct 5 ms 1256 KB Output is correct
42 Correct 4 ms 1248 KB Output is correct
43 Incorrect 0 ms 212 KB Output isn't correct
44 Halted 0 ms 0 KB -