This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
x, y = map(int, input().split())
a[i] = x
b[i] = y
# subtask 1 only
ans = 0
extra = 0
for i in range(n):
ans += abs(extra)
extra += a[i] - b[i]
print(ans)
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |