/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
ll n;
cin>>n;
vector<pair<ll,ll>> v(n);
for(ll i=0;i<n;i++){
cin>>v[i].first>>v[i].second;
}
sort(v.begin(),v.end());
ll ans = 0;
for(ll i=0;i<n;i++){
ll tot = 0 , mi = 1e10, ma = 0;
for(ll j=i;j<n;j++){
tot += v[j].second;
mi = min(mi,v[j].first);
ma = max(ma,v[j].first);
ans = max(ans,tot - (ma - mi));
//cout<<i<<" "<<j<<" "<<tot<<" "<<ma<<" "<<mi<<" "<<ans<<endl;
}
}
cout<<ans<<endl;
}
int main()
{
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |