Submission #799171

#TimeUsernameProblemLanguageResultExecution timeMemory
799171AndiRFuel Station (NOI20_fuelstation)C++14
100 / 100
287 ms24704 KiB
#include <iostream> #include <queue> #include <vector> #include <algorithm> using namespace std; typedef long long ll; const ll Nmax=300000; ll n, d; struct station{ ll x, a, b; }v[Nmax+1]; priority_queue <pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> q; bool cmp(station a, station b){ return a.x<b.x; } int main() { cin>>n>>d; for (ll i=0; i<n; i++) cin>>v[i].x>>v[i].a>>v[i].b; sort(v, v+n, cmp); v[n].x=d; v[n].b=d+1; ll fs=0, fadd=0; for (ll i=0; i<=n; i++){ while (v[i].x>fs+fadd && fs<=v[i].b){ fs=v[i].x-fadd; while (!q.empty() && q.top().first<fs){ fadd-=q.top().second; q.pop(); } } if (fs<=v[i].b){ fadd+=v[i].a; q.push({v[i].b, v[i].a}); } } cout<<fs; 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...