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