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;
typedef long long ll;
typedef long double ld;
pair <ll, ll> niz[500005];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.precision(10);
cout << fixed;
int n;
cin >> n;
for(int i=1; i<=n; i++){
cin >> niz[i].first >> niz[i].second;
}
sort(niz+1, niz+1+n);
ll res = 0;
ll sum = 0;
for(int i=1; i<=n; i++){
sum += niz[i].second;
res = max(res, sum);
sum += niz[i].first - niz[i+1].first;
sum = max(0LL, sum);
}
cout << res;
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... |