Submission #952672

#TimeUsernameProblemLanguageResultExecution timeMemory
952672Mohamed_Kachef06Fuel Station (NOI20_fuelstation)C++17
0 / 100
3034 ms36784 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; for (int F = 0 ; F < N ; F++){ for (int j = B[F][2] + 1 ; j <= N ; j++) x[j] += B[F][1]; 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...