Submission #799168

#TimeUsernameProblemLanguageResultExecution timeMemory
799168AndiRFuel Station (NOI20_fuelstation)C++14
36 / 100
276 ms13944 KiB
#include <iostream> #include <queue> #include <vector> #include <algorithm> using namespace std; const int Nmax=300000; int n, d; struct station{ int x, a, b; }v[Nmax+1]; priority_queue <pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q; bool cmp(station a, station b){ return a.x<b.x; } int main() { cin>>n>>d; for (int 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; int fs=0, fadd=0; for (int 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...