Submission #547056

#TimeUsernameProblemLanguageResultExecution timeMemory
547056d2k05Fuel Station (NOI20_fuelstation)C++14
0 / 100
231 ms12792 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 1e6 + 5; int n, d; pair <int, pair <int, int> > a[N]; double mx(double f) { double cur = f, now = 0; for (int i = 1; i <= n; ++i) { if (cur >= a[i].first - now) { cur -= a[i].first - now; now = a[i].first; } else return now + cur; if (f <= a[i].second.second) cur += a[i].second.first; } return min(d * 1.0, now + cur); } int main() { ios :: sync_with_stdio(0), cin.tie(0); cin >> n >> d; for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second.first >> a[i].second.second; sort(a + 1, a + 1 + n); double lb = 0, rb = d; for (int i = 0; i < 100; ++i) { double md1 = lb + (rb - lb) / 3; double md2 = rb - (rb - lb) / 3; if (md2 < md1) break; if (mx(md1) > mx(md2)) { rb = md2; } else if (mx(md1) < mx(md2)) { lb = md1; } else { rb = md1; } } cout << lb; return 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...