Submission #951952

#TimeUsernameProblemLanguageResultExecution timeMemory
951952Mohamed_Kachef06Fuel Station (NOI20_fuelstation)C++17
54 / 100
3087 ms18192 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<int> B; for (int i = 0 ; i < N ; i++){ int x , a , b ; cin >> x >> a >> b; v.push_back({x , a , b}); B.push_back(b); } B.push_back(1e18); v.push_back({D , 0 , 0}); sort(v.begin() , v.end()); sort(B.begin() , B.end()); int ans = 1e18; for (int F = 0 ; F <= N ; F++){ int mn = 0; int sum = 0; for (int i = 0 ; i <= N ; i++){ mn = min(mn , sum - v[i][0]); if (B[F] <= v[i][2]) sum += v[i][1]; } if (-mn <= B[F]) 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...