이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int N;
pair<long long, int> X[505050];
int main(){
cin>>N;
for(int i=0; i<N;i++){
long long A; int B;
cin>>A>>B;
X[i]=make_pair(A,B);
}
sort(X, X+N);
long long ret=0, acc=0, lo=0;
for(int i=0; i<N; i++){
lo=min(lo, acc-X[i].first);
acc+=X[i].second;
ret = max(ret, acc-X[i].first-lo);
}
cout<<ret<<endl;
}
# | 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... |