Submission #1106587

#TimeUsernameProblemLanguageResultExecution timeMemory
1106587Canuc80kPotatoes and fertilizers (LMIO19_bulves)C++17
24 / 100
55 ms23624 KiB
#include "bits/stdc++.h" using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; const ll N = 1e6 + 1; const ll M = 1e9 + 7; ll n; ll a[N], b[N], f[N]; void doTest(ll testID) { cin >> n; for (int i = 1; i <= n; i ++) cin >> a[i] >> b[i]; ll res = 0; for (int i = 1; i <= n; i ++) f[i] = f[i - 1] + (a[i] - b[i]); for (int i = 1; i <= n; i ++) res += abs(f[i]); cout << res; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int test = 1; // cin >> test; for (int _ = 1; _ <= test; _ ++) doTest(_); }
#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...