#include <bits/stdc++.h>
#define N 500005
#define ll long long int
#define pii pair <long long, long long>
#define pb push_back
#define ff first
#define ss second
using namespace std;
ll t, n, S, mx, c[N], mn = 1e18, ans;
pii a[N];
// void bit (int x){
// if (x == n + 1){
// S = mx = 0;
// mn = 1e9;
// for (int i = 1; i <= n; i++){
// if (c[i]){
// S += a[i].ss;
// mx = max(mx, a[i].ff);
// mn = min(mn, a[i].ff);
// }
// if (S - (mx - mn) == 7){
// for (int i = 1; i <= n; i++) cout << c[i] << " ";
// exit(0);
// }
// }
// return;
// }
// for (int i = 0; i < 2; i++) c[x] = i, bit(x + 1);
// }
int main ()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i].ff >> a[i].ss;
// bit(1);
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; i++){
S += a[i].ss;
mx = max(mx, a[i].ff);
mn = min(mn, a[i].ff);
ans = max(ans, S - (mx - mn));
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |