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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
long long int n;
cin>>n;
vector<pair<long long int,long long int> >art(n+1);
art[0]=make_pair(0,0);
for(int i=1;i<=n;i++)cin>>art[i].first>>art[i].second;
sort(art.begin(),art.end());
for(int i=1;i<=n;i++){
art[i].second+=art[i-1].second;
}
long long int maxi=0;
for(int i=0;i<n;i++){
for(int j=i+1;j<=n;j++){
long long int dist=art[j].first-art[i+1].first;
long long int val=art[j].second-art[i].second;
if(val-dist>maxi)maxi=val-dist;
}
}
cout<<maxi<<'\n';
}
# | 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... |