Submission #655055

#TimeUsernameProblemLanguageResultExecution timeMemory
655055horiseunFuel Station (NOI20_fuelstation)C++11
13 / 100
178 ms14648 KiB
#include <iostream> #include <vector> #include <tuple> #include <algorithm> using namespace std; int n, d, a, b, x, l, r, m; vector<tuple<int, int, int>> stops; bool valid(int f) { int cd = 0; for (int i = 1; i < stops.size(); i++) { tie(x, a, b) = stops[i]; f -= (x - get<0>(stops[i - 1])); if (f < 0) return false; if (f <= b) f += a; } return true; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> d; for (int i = 0; i < n; i++) { cin >> x >> a >> b; if (x > d) continue; stops.push_back({x, a, b}); } stops.push_back({0, 0, 0}); sort(stops.begin(), stops.end()); l = 0, r = 1e9 + 5; while (l + 1 != r) { m = (l + r) / 2; if (valid(m)) r = m; else l = m; } cout << r << "\n"; }

Compilation message (stderr)

FuelStation.cpp: In function 'bool valid(int)':
FuelStation.cpp:12:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int i = 1; i < stops.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~
FuelStation.cpp:11:9: warning: unused variable 'cd' [-Wunused-variable]
   11 |     int cd = 0;
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...