n = int(input())
paintings = []
for i in range(n):
paintings.append(list(map(int, input().split())))
paintings.sort()
curmax = -1
curmin = float("inf")
cur = 0
ans = 0
for i in range(n):
curmax = max(curmax, paintings[i][0])
curmin = min(curmin, paintings[i][0])
cur += paintings[i][1]
ans = max(ans, cur-(curmax-curmin))
print(ans)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
18228 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
18228 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
18228 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
18228 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |