Submission #334340

#TimeUsernameProblemLanguageResultExecution timeMemory
334340limabeansPotatoes and fertilizers (LMIO19_bulves)C++17
24 / 100
181 ms12140 KiB
#include <bits/stdc++.h> using namespace std; template<typename T> void out(T x) { cout << x << endl; exit(0); } #define watch(x) cout << (#x) << " is " << (x) << endl using ll = long long; const int maxn = 1e6 + 5; int n; ll a[maxn]; ll b[maxn]; ll c[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; for (int i=1; i<=n; i++) { cin>>a[i]>>b[i]; c[i]=a[i]-b[i]+c[i-1]; } ll res = 0; for (int i=1; i<n; i++) { res += abs(c[i]); } cout<<res<<endl; return 0; }
#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...