이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
long long n,i,l,r,mx,ans; pair<long long,long long> p[500005];
int main(){
cin>>n;
for (i=1; i<=n; i++)
cin>>p[i].first>>p[i].second;
sort(p+1,p+n+1); ans=mx=LLONG_MIN;
for (r=1; r<=n; r++){
p[r].second+=p[r-1].second;
mx=max(mx,p[r].first-p[r-1].second);
ans=max(ans,p[r].second-p[r].first+mx);
}
cout<<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... |