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;
int main()
{
int n ;
cin >> n ;
vector<pair<int , int > > v(n);
for(auto &it : v)cin >> it.first >> it.second ;
sort(v.begin() , v.end());
int ans = 0 ;
int sum = 0 ;
int past = 0 ;
for(int i = n - 1 ; i >= 0 ; i --){
if(i != n - 1)sum += v[i].second - (past - v[i].first);
sum = max(sum , v[i].second);
past = v[i].first ;
ans = max(ans , sum);
}
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... |