#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve()
{
ll n;
cin >> n;
ll ans = 0, cur = 0;
while (n--)
{
ll a, b;
cin >> a >> b;
cur += a - b;
ans += abs(cur);
}
cout << ans << endl;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
ll t = 1;
// precomp();
// cin >> t;
for (ll cs = 1; cs <= t; cs++)
solve();
cerr << "\nTime elapsed: " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
784 KB |
Output is correct |
5 |
Correct |
9 ms |
860 KB |
Output is correct |
6 |
Correct |
30 ms |
3640 KB |
Output is correct |
7 |
Correct |
60 ms |
6988 KB |
Output is correct |
8 |
Correct |
49 ms |
5180 KB |
Output is correct |
9 |
Correct |
48 ms |
4532 KB |
Output is correct |
10 |
Correct |
34 ms |
2388 KB |
Output is correct |
11 |
Correct |
34 ms |
2228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
784 KB |
Output is correct |
5 |
Correct |
9 ms |
860 KB |
Output is correct |
6 |
Correct |
30 ms |
3640 KB |
Output is correct |
7 |
Correct |
60 ms |
6988 KB |
Output is correct |
8 |
Correct |
49 ms |
5180 KB |
Output is correct |
9 |
Correct |
48 ms |
4532 KB |
Output is correct |
10 |
Correct |
34 ms |
2388 KB |
Output is correct |
11 |
Correct |
34 ms |
2228 KB |
Output is correct |
12 |
Incorrect |
18 ms |
2136 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
0 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 |
0 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 |
- |