#include <bits/stdc++.h>
using namespace std;
#define NAME "name"
#define ll long long
#define pb push_back
#define pii pair<ll, ll>
#define fi first
#define se second
#define endl "\n"
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
const int LIM = 1e6 + 3;
const int INF = 1e9 + 9;
const int mod = 1e9 + 7;
int n;
pii a[LIM];
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i].fi >> a[i].se;
sort(a + 1, a + n + 1);
ll mines = a[1].fi, ans = 0;
for (int i = 1; i <= n; i++)
{
a[i].se += a[i - 1].se;
ans = max(ans, a[i].se - a[i].fi - mines);
mines = min(mines, a[i - 1].se - a[i].fi);
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |