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 all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
const ll inf = 1e15 + 10000;
const int mod = 1e9+7;
const int maxn = 5e5 + 12;
void solve() {
int n;
cin >> n;
pll a[n];
ll ans = 0, s = 0, t = inf;
for(int i = 0; i < n; i++) {
cin >> a[i].ff >> a[i].ss;
}
sort(a, a + n);
for(int i = 0; i < n; i++) {
t = min(t, s - a[i].ff);
s += a[i].ss;
ans = max(ans, s - a[i].ff - t);
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int times = 1;
//cin >> times;
for(int i = 1; i <= times; i++) {
solve();
}
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... |