#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
struct slika
{
int vel;
int vr;
};
slika a[500005];
int kum[500005];
int32_t main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i].vel >> a[i].vr;
sort(a, a+n, [](slika pr, slika dr){
return pr.vel < dr.vel;
});
for (int i = 1; i <= n; i++)
kum[i] = kum[i-1]+a[i-1].vr;
int rez = 0, str = 0;
for (int i = 0; i < n; i++)
{
rez = max(rez, kum[i+1]-kum[str]-a[i].vel+a[str].vel);
if (a[i].vel > kum[i]-kum[str]+a[str].vel)
str = i;
}
cout << rez << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |