# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
# define int long long
using namespace std;
const int N = 5e5 + 7;
const int mod = 1e9 + 7;
pair < int, int > vc[N];
int sum[N], ans = -1e18;
int32_t main() {
speed;
int n;
cin >> n;
for ( int i = 1; i <= n; i++ ) {
cin >> vc[i].first >> vc[i].second;
}
sort( vc + 1, vc + 1 + n );
for ( int i = 1; i <= n; i++ ) {
sum[i] = sum[i - 1] + vc[i].second;
}
set < int > st;
for ( int k = 1; k <= n; k++ ) {
st.insert( sum[k - 1] + vc[k].first );
int x = *st.begin();
ans = max( ans, sum[k] - vc[k].first + x );
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |