Submission #547059

#TimeUsernameProblemLanguageResultExecution timeMemory
547059d2k05Fuel Station (NOI20_fuelstation)C++14
37 / 100
3076 ms7244 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); int bruh = 0; while (mx(bruh) != d) ++bruh; cout << bruh; 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...