Submission #546962

#TimeUsernameProblemLanguageResultExecution timeMemory
546962socpiteFuel Station (NOI20_fuelstation)C++14
24 / 100
3025 ms7108 KiB
#include<bits/stdc++.h> using namespace std; #define f first #define s second typedef long long ll; typedef pair<int, int> pii; const int maxn = 3e5+5; int n, D; int ans, crr; pair<int, pii> fuel[maxn]; int sB[maxn]; int main(){ cin >> n >> D; fuel[0].f = 0; for(int i = 1; i <= n; i++){ cin >> fuel[i].f >> fuel[i].s.f >> fuel[i].s.s; sB[i] = fuel[i].s.s; } sort(sB+1, sB+n+1); sort(fuel+1, fuel+n+1); for(int i = 1; i <= n; i++){ int crr = 0, ff = 0, gg = 1; for(int j = 1; j <= n; j++){ crr-=fuel[j].f-fuel[j-1].f; if(crr < 0){ ff-=crr; crr = 0; } if(fuel[j].s.s >= sB[i])crr+=fuel[j].s.f; if(ff > sB[i]){ gg = 0; break; } } crr -= D-fuel[n].f; if(crr < 0){ ff-=crr; crr = 0; } if(ff > sB[i])gg=0; if(gg){ cout << ff; return 0; } } cout << D; }
#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...