#include <bits/stdc++.h>
#define int int64_t
#define ii pair<int,int>
#define x first
#define y second
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<ii>
#define vvii vector<vii>
#define vb vector<bool>
#define vvb vector<vb>
#define pb push_back
#define loop(i,s,e) for(int i=(s);i<(e);i++)
#define loopr(i,s,e) for(int i=(e)-1;i>=(s);i--)
#define chkmax(a,b) a = max(a,b)
#define chkmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
using namespace std;
const int INF = 1e18;
const int MOD = (int(1)<<31) - 1;
int32_t main(){
ios_base::sync_with_stdio(false);
int n; cin>>n;
int c = 0, ans = 0,a,b;
loop(i,0,n){
cin>>a>>b;
c+=a-b;
ans+=abs(c);
}
cout<<ans<<endl;
return 0;
}
/*
color a
cls
g++ CuttingRectangle.cpp -o a & a
6
1 2
0 0
2 0
0 0
0 0
0 1
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
8 ms |
620 KB |
Output is correct |
5 |
Correct |
16 ms |
1004 KB |
Output is correct |
6 |
Correct |
49 ms |
3692 KB |
Output is correct |
7 |
Correct |
99 ms |
7148 KB |
Output is correct |
8 |
Correct |
86 ms |
5356 KB |
Output is correct |
9 |
Correct |
82 ms |
4588 KB |
Output is correct |
10 |
Correct |
66 ms |
2284 KB |
Output is correct |
11 |
Correct |
65 ms |
2304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
8 ms |
620 KB |
Output is correct |
5 |
Correct |
16 ms |
1004 KB |
Output is correct |
6 |
Correct |
49 ms |
3692 KB |
Output is correct |
7 |
Correct |
99 ms |
7148 KB |
Output is correct |
8 |
Correct |
86 ms |
5356 KB |
Output is correct |
9 |
Correct |
82 ms |
4588 KB |
Output is correct |
10 |
Correct |
66 ms |
2284 KB |
Output is correct |
11 |
Correct |
65 ms |
2304 KB |
Output is correct |
12 |
Incorrect |
27 ms |
2028 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
384 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 |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
364 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 |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |