Submission #952674

#TimeUsernameProblemLanguageResultExecution timeMemory
952674Mohamed_Kachef06Fuel Station (NOI20_fuelstation)C++17
0 / 100
3103 ms27336 KiB
#include <bits/stdc++.h> using namespace std; #define int long long void doWork(){ int N , D; cin >> N >> D; vector<array<int, 3>> v; vector<array<int , 3>> B; for (int i = 0 ; i < N ; i++){ int x , a , b ; cin >> x >> a >> b; v.push_back({x , a , b}); } v.push_back({D , 0 , 0}); sort(v.begin() , v.end()); for (int i = 0 ; i < N ; i++){ B.push_back({v[i][2], v[i][1] , i}); } sort(B.begin() , B.end()); int x[N+1] = {}; for (int i = 0 ; i <= N ; i++){ x[i] = - v[i][0]; } int ans = 1e18; int id = 0; for (int F = 0 ; F < N ; F++){ while(id <= N && B[id][0] <= B[F][0]) { for (int j = B[id][2] + 1 ; j <= N ; j++) x[j] += B[id][1]; id++; } int mn = 0; for (int j = 0 ; j <= N ; j++) {mn = min(mn , x[j]); } if (-mn <= B[F][0]) ans = min(ans , -mn); } cout << ans; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); doWork(); }
#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...