Submission #709699

# Submission time Handle Problem Language Result Execution time Memory
709699 2023-03-14T08:07:36 Z awu Fuel Station (NOI20_fuelstation) C++14
39 / 100
139 ms 27280 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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 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 1 ms 212 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 127 ms 27252 KB Output is correct
2 Correct 132 ms 27272 KB Output is correct
3 Correct 134 ms 27268 KB Output is correct
4 Correct 122 ms 27208 KB Output is correct
5 Correct 128 ms 27184 KB Output is correct
6 Correct 125 ms 27268 KB Output is correct
7 Correct 127 ms 27264 KB Output is correct
8 Correct 118 ms 27260 KB Output is correct
9 Correct 126 ms 27256 KB Output is correct
10 Correct 129 ms 27252 KB Output is correct
11 Correct 138 ms 27208 KB Output is correct
12 Correct 128 ms 27244 KB Output is correct
13 Correct 126 ms 27256 KB Output is correct
14 Correct 136 ms 27252 KB Output is correct
15 Correct 128 ms 27256 KB Output is correct
16 Correct 132 ms 27260 KB Output is correct
17 Correct 130 ms 27208 KB Output is correct
18 Correct 139 ms 27264 KB Output is correct
19 Correct 123 ms 27200 KB Output is correct
20 Correct 128 ms 27280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 4 ms 1208 KB Output is correct
3 Correct 4 ms 1256 KB Output is correct
4 Correct 4 ms 1232 KB Output is correct
5 Correct 5 ms 1256 KB Output is correct
6 Correct 4 ms 1256 KB Output is correct
7 Correct 6 ms 1200 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 4 ms 1208 KB Output is correct
3 Correct 4 ms 1256 KB Output is correct
4 Correct 4 ms 1232 KB Output is correct
5 Correct 5 ms 1256 KB Output is correct
6 Correct 4 ms 1256 KB Output is correct
7 Correct 6 ms 1200 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 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 1 ms 212 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 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 320 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 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 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 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 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 1 ms 212 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 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 1208 KB Output is correct
18 Correct 4 ms 1256 KB Output is correct
19 Correct 4 ms 1232 KB Output is correct
20 Correct 5 ms 1256 KB Output is correct
21 Correct 4 ms 1256 KB Output is correct
22 Correct 6 ms 1200 KB Output is correct
23 Incorrect 1 ms 212 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 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 1 ms 212 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 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 127 ms 27252 KB Output is correct
17 Correct 132 ms 27272 KB Output is correct
18 Correct 134 ms 27268 KB Output is correct
19 Correct 122 ms 27208 KB Output is correct
20 Correct 128 ms 27184 KB Output is correct
21 Correct 125 ms 27268 KB Output is correct
22 Correct 127 ms 27264 KB Output is correct
23 Correct 118 ms 27260 KB Output is correct
24 Correct 126 ms 27256 KB Output is correct
25 Correct 129 ms 27252 KB Output is correct
26 Correct 138 ms 27208 KB Output is correct
27 Correct 128 ms 27244 KB Output is correct
28 Correct 126 ms 27256 KB Output is correct
29 Correct 136 ms 27252 KB Output is correct
30 Correct 128 ms 27256 KB Output is correct
31 Correct 132 ms 27260 KB Output is correct
32 Correct 130 ms 27208 KB Output is correct
33 Correct 139 ms 27264 KB Output is correct
34 Correct 123 ms 27200 KB Output is correct
35 Correct 128 ms 27280 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 4 ms 1208 KB Output is correct
38 Correct 4 ms 1256 KB Output is correct
39 Correct 4 ms 1232 KB Output is correct
40 Correct 5 ms 1256 KB Output is correct
41 Correct 4 ms 1256 KB Output is correct
42 Correct 6 ms 1200 KB Output is correct
43 Incorrect 1 ms 212 KB Output isn't correct
44 Halted 0 ms 0 KB -