Submission #951947

#TimeUsernameProblemLanguageResultExecution timeMemory
951947Mohamed_Kachef06Fuel Station (NOI20_fuelstation)C++17
54 / 100
3027 ms17788 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 = 1e18; int sum = B[F]; 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 >= 0) ans = min(ans , B[F] - 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...