#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
long long n;
cin >> n;
auto ab = new pair<long long, long long>[n];
for (long long 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 (long long i = 0; i < n; i++)
{
s += ab[i].second;
while (amin + 1 < n && (s - (ab[i].first - ab[amin].first) < s - ab[amin].second - (ab[i].first - ab[amin + 1].first)))
{
s -= ab[amin].second;
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 |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |