#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
using namespace std;
int32_t main(){
fast
int n;
cin >> n;
int need = 0, ans = 0;
for(int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
int ai = b - a;
need += ai;
ans += abs(need);
}
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
604 KB |
Output is correct |
5 |
Correct |
10 ms |
860 KB |
Output is correct |
6 |
Correct |
30 ms |
3632 KB |
Output is correct |
7 |
Correct |
60 ms |
6996 KB |
Output is correct |
8 |
Correct |
49 ms |
5164 KB |
Output is correct |
9 |
Correct |
48 ms |
4436 KB |
Output is correct |
10 |
Correct |
45 ms |
2352 KB |
Output is correct |
11 |
Correct |
35 ms |
2384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
604 KB |
Output is correct |
5 |
Correct |
10 ms |
860 KB |
Output is correct |
6 |
Correct |
30 ms |
3632 KB |
Output is correct |
7 |
Correct |
60 ms |
6996 KB |
Output is correct |
8 |
Correct |
49 ms |
5164 KB |
Output is correct |
9 |
Correct |
48 ms |
4436 KB |
Output is correct |
10 |
Correct |
45 ms |
2352 KB |
Output is correct |
11 |
Correct |
35 ms |
2384 KB |
Output is correct |
12 |
Incorrect |
15 ms |
1884 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |