Submission #951220

#TimeUsernameProblemLanguageResultExecution timeMemory
951220NourWaelFuel Station (NOI20_fuelstation)C++17
24 / 100
3072 ms11840 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int const mxN = 3e5+5; vector<pair<int,pair<int,int>>>a; signed main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n,d; cin>>n>>d; a.resize(n+1); for(int i=0; i<n; i++) cin>>a[i].first>>a[i].second.first>>a[i].second.second; a[n] = {d,{0,0}}; sort(a.begin(),a.end()); for(int i=1; i<=d; i++) { int mid = i, now = i; bool f = 1; if(mid<a[0].first) f = 0; else now -= a[0].first; for(int j=0; j<n; j++) { if(mid<=a[j].second.second) now += a[j].second.first; if(now<abs(a[j+1].first-a[j].first)) { f = 0; break; } now -= abs(a[j+1].first-a[j].first); } if(f) { cout<<mid<<'\n'; return 0; } } 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...