Submission #713638

#TimeUsernameProblemLanguageResultExecution timeMemory
713638mtxasPotatoes and fertilizers (LMIO19_bulves)C++14
24 / 100
88 ms14780 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #define int long long #define DISABLE_PRINTF #ifdef DISABLE_PRINTF #define printf(...) #endif // DISABLE_PRINTF using namespace std; void solve() { int n; cin >> n; vector<int> a(n + 1), b(n + 1); for(int i = 1; i <= n; ++i) { cin >> a[i] >> b[i]; } /// solve it int ans = 0; int aid = 1, bid = 1; for(; bid <= n; ++bid) { for(; b[bid] > 0; ++aid) { int take = min(a[aid], b[bid]); b[bid] -= take; a[aid] -= take; ans += take * abs(bid - aid); if(b[bid] == 0) { break; } } } cout<<ans; } signed main() { #ifdef EVAL cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); #endif // EVAL solve(); }
#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...