from sys import stdin
range = xrange
raw_input = stdin.readline
N = int(raw_input())
L = [None]*N
for i in range(N):
a, b = map(int, raw_input().split())
L[i] = (a, b)
L.sort()
S = [0]*(N+1)
for i in range(N):
a, b = L[i]
S[i+1] = S[i] + b
ans = 0
for j in range(N):
for i in range(j):
ans = max(ans, S[j+1] - S[i] + L[i][0] - L[j][0])
print ans
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
10984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
10984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
10984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
10984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |