This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Muallif: Azimjon Mehmonali o'g'li
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long double PI = 3.1415926535897;
const int mod = 1000000007LL;
const int INF = 1e18;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<pair<int, int>> v(n);
for (auto &[x, y] : v) {
cin >> x >> y;
}
sort(v.begin(), v.end());
int jv, ki, yi;
jv = ki = yi = 0;
for (int i = 0; i < n; i++) {
ki = min(ki, yi - v[i].first);
yi += v[i].second;
jv = max(jv, yi - v[i].first - ki);
}
cout << jv << endl;
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... |