#include <bits/stdc++.h>
using namespace std;
long long n ;
vector< pair<long long , long long> >vp ;
int main()
{
cin>>n ;
for(long long i = 0 ; i < n ; ++i)
{
long long x , y ;
cin>>x>>y ;
vp.push_back({x , y});
}
sort(vp.begin() , vp.end());
long long ans = 0 ;
for(long long i = 0 ; i < n ; ++i)
{
long long MAX = vp[i].first , MIN = vp[i].first , sum = vp[i].second ;
for(long long j = i+1 ; j < n ; ++j)
{
MAX = max(MAX , vp[j].first * 1ll);
MIN = min(MIN , vp[j].first * 1ll);
sum += vp[j].second * 1ll;
ans = max(ans , sum - MAX + MIN) * 1ll;
}
}
return cout<<ans , 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |