Submission #471337

#TimeUsernameProblemLanguageResultExecution timeMemory
471337piotruloPotatoes and fertilizers (LMIO19_bulves)C++14
0 / 100
24 ms1116 KiB
#include <bits/stdc++.h> using namespace std; #define st first #define nd second int main() { int n; cin>>n; vector<int> v; vector<int> sum; for(int i=0; i<n; i++) { int a,b; cin>>a>>b; v.push_back(a-b); if(i>0) sum.push_back(sum[sum.size()-1]+a-b); else sum.push_back(a-b); } int ile=0; int res=0; for(int i=0; i<n; i++) { ile+=v[i]; if(ile<=0) res-=ile; else if(sum[sum.size()-1]-sum[i]<0) res-=sum[sum.size()-1]-sum[i]; } cout<<res; }
#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...