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>
#define ll int
#define pb push_back
using namespace std;
int n,m,a,b,c,cnt,g,f,d,e,cvp,k;
pair<ll,ll> dizi[100005];
int fark[100005];
string s;
int main()
{
cin>>n;
for (int i=0;i<n;i++)
cin>>dizi[i].first>>dizi[i].second;
sort(dizi,dizi+n);
ll toplam=dizi[n-1].second;
ll kntrl=dizi[n-1].first;
ll cvp=toplam;
for (int i=n-2;i>=0;i--)
{
toplam+=dizi[i].second-(kntrl-dizi[i].first);
toplam=max(toplam,dizi[i].second);
kntrl=dizi[i].first;
cvp=max(cvp,toplam);
}
cout<<cvp;
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... |