#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n;
cin >> n;
auto ab = new pair<long long, long long>[n];
for (int i = 0; i < n; i++)
{
cin >> ab[i].first >> ab[i].second;
}
std::sort(ab, ab + n);
long long amin = 0;
long long s = 0;
long long m = 0;
for (int i = 0; i < n; i++)
{
s += ab[i].second;
while (s - (ab[i].first - ab[amin].first) < s - ab[amin].second - (ab[i].first - ab[amin + 1].first))
{
amin++;
}
if (s - (ab[i].first - ab[amin].first) > m)
{
m = s - (ab[i].first - ab[amin].first);
}
}
cout << m << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |