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