This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//sat
#include <chrono>
using namespace std::chrono;
#define vremestart auto start = high_resolution_clock::now();
#define vremeend auto stop = high_resolution_clock::now();
#define vremeispis auto duration = duration_cast<microseconds>(stop - start); cout << duration.count() << endl;
//sat
#include <bits/stdc++.h>
#define mod 998244353
#define gcd __gcd
#define ll long long
#define ull unsigned long long
#define llinf 9223372036854775807
#define iinf 2147483647
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define rall(a) a.begin(),a.end(),greater<int>()
using namespace std;
#define maxn 500005
pll a[maxn];
int n;
int main(){
ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
cin >> n;
for(int i = 1;i<=n;i++) cin >> a[i].fi >> a[i].sc;
sort(a+1,a+n+1);
ll sum = 0;
ll maxx = -llinf;
ll ans = -llinf;
for(int i = 1;i<=n;i++){
maxx = max(maxx,a[i].fi-sum);
sum+=a[i].sc;
ans = max(ans,maxx+sum-a[i].fi);
}
cout<<ans;
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... |