Submission #599042

#TimeUsernameProblemLanguageResultExecution timeMemory
599042almothana05Potatoes and fertilizers (LMIO19_bulves)C++14
0 / 100
10 ms2188 KiB
#include<bits/stdc++.h> #define mod 1000000007 using namespace std; vector<vector<int> >cmp; vector<int>num; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int menge , numm , nummer , erg = 0;; cin >> menge; for(int i = 0 ; i < menge; i++){ cin >> numm >> nummer; if(numm > 0){ cmp.push_back({numm , i}); } num.push_back(nummer); } int pl = cmp.size() - 1; for(int 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...