Submission #473516

#TimeUsernameProblemLanguageResultExecution timeMemory
473516FgdxxPotatoes and fertilizers (LMIO19_bulves)C++17
0 / 100
30 ms2116 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; vector<long long>odp1(n); priority_queue<long long,vector<long long>,greater<long long>>odp2; for(auto &x : odp1) { int a,b; cin>>a>>b; x=(b-a); odp2.push(0); } partial_sum(odp1.begin(),odp1.end(),odp1.begin()); odp2.push(0); odp2.push(0); int punkty=0; for(auto x : odp1 ) { odp2.pop(); punkty+=max(-x-odp2.top(),0LL); odp2.push(-x); odp2.push(-x); } long long wi=0; while(odp2.top()!=-odp1.back()) { auto m=odp2.top(); odp2.pop(); punkty+=wi*(odp2.top()-m); wi++; } cout<<punkty; 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...