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;
typedef pair<ll,ll> pi;
pi A[5005];
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n; cin>>n;
for(int i=1; i<=n; i++) cin>>A[i].first>>A[i].second;
sort(A+1,A+n+1);
for(int i=2; i<=n; i++) A[i].second+=A[i-1].second;
ll ans = 0;
for(int i=1; i<=n; i++){
for(int j=i; j<=n; j++){
ll s = A[j].second - A[i-1].second;
s-=A[j].first-A[i].first;
ans = max(ans,s);
}
}
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... |