Submission #599044

#TimeUsernameProblemLanguageResultExecution timeMemory
599044almothana05Potatoes and fertilizers (LMIO19_bulves)C++14
24 / 100
124 ms38260 KiB
#include<bits/stdc++.h> #define mod 1000000007 using namespace std; vector<vector<long long> >cmp; vector<long long>num; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); long long menge , numm , nummer , erg = 0;; cin >> menge; for(long long i = 0 ; i < menge; i++){ cin >> numm >> nummer; if(numm > 0){ cmp.push_back({numm , i}); } num.push_back(nummer); } long long pl = cmp.size() - 1; for(long long i = menge - 1; i >= 0 ; i--){ while(num[i]){ if(cmp[pl][0] == 0){ pl--; } if(pl < 0){ break; } nummer = min(num[i], cmp[pl][0]); num[i] -= nummer; cmp[pl][0] -= nummer; erg += nummer * abs(i - cmp[pl][1]); } } cout << erg << "\n"; }
#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...