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 long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,ta,tb,tem,has;
pair<ll,ll> a[505050];
vector<ll> v;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
for(i=1;i<=n;i++)
{
cin>>ta>>tb;
a[i]=mp(ta,tb);
}
sort(a+1,a+1+n);
for(i=1;i<=n;i++)
{
v.pb(-a[i].se);
v.pb(a[i].se);
if(i<n)
v.pb((a[i+1].se)-(a[i+1].fi-a[i].fi));
}
for(i=0;i<v.size();i++)
{
tem+=v[i];
tem=max(tem,0LL);
has=max(has,tem);
}
cout<<has<<"\n";
}
Compilation message (stderr)
art.cpp: In function 'int main()':
art.cpp:28:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=0;i<v.size();i++)
~^~~~~~~~~
# | 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... |