#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 time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
18 ms |
1516 KB |
Output is correct |
5 |
Correct |
33 ms |
2668 KB |
Output is correct |
6 |
Correct |
49 ms |
6252 KB |
Output is correct |
7 |
Correct |
181 ms |
12140 KB |
Output is correct |
8 |
Correct |
85 ms |
12140 KB |
Output is correct |
9 |
Correct |
102 ms |
12056 KB |
Output is correct |
10 |
Correct |
70 ms |
12140 KB |
Output is correct |
11 |
Correct |
67 ms |
12128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
18 ms |
1516 KB |
Output is correct |
5 |
Correct |
33 ms |
2668 KB |
Output is correct |
6 |
Correct |
49 ms |
6252 KB |
Output is correct |
7 |
Correct |
181 ms |
12140 KB |
Output is correct |
8 |
Correct |
85 ms |
12140 KB |
Output is correct |
9 |
Correct |
102 ms |
12056 KB |
Output is correct |
10 |
Correct |
70 ms |
12140 KB |
Output is correct |
11 |
Correct |
67 ms |
12128 KB |
Output is correct |
12 |
Incorrect |
25 ms |
3308 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |