This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct art{
ll a,b;
bool operator<(const art &tmp)const{
return a<tmp.a;
}
};
int N;
art A[500001];
ll Ans;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>N;
for (int i=1; i<=N; i++)
cin>>A[i].a>>A[i].b;
sort(A+1,A+N+1);
for (int i=1; i<=N; i++)
A[i].b+=A[i-1].b;
ll tmp=-A[1].a;
for (int i=2; i<=N; i++){
Ans=max(Ans,A[i].b-A[i].a-tmp);
tmp=min(tmp,A[i-1].b-A[i].a);
}
cout<<Ans;
return 0;
}
# | 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... |