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())
li=[[*map(int,input().split())]for _ in range(n)]
li.sort(key=lambda x:x[0])
li2=[]
for i in range(n):
if(i==0):li2.append(li[i][1])
else:li2.append(li[i][1]-(li[i][0]-li[i-1][0]))
s=[li2[0]]
for i in range(n-1):
s.append(max(s[i]+li2[i+1],li2[i+1]))
print(max(s))
# | 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... |