#include <bits/stdc++.h>
using namespace std;
//typedef long long ll;
///typedef unsigned long long ull;
//typedef pair<long long,long long> pl;
#define all(s) s.begin(),s.end()
#define F first
#define S second
#define sz(a) a.size()
#define int long long
typedef pair<int,int> pi;
//const ll mod = 998244353;
//const ll mod1 = 1e9+7;
//const ll INF = 1e18;
const int N = 100200;
const int inf = 1e18+200;
int n;
pi a[N*5];
int p[N*5];
void solve() {
cin>>n;
for(int i=1;i<=n;++i) {
cin>>a[i].F>>a[i].S;
}
sort(a+1,a+1+n);
for(int i=1;i<=n;++i) {
p[i]=p[i-1]+a[i].S;
}
int ans=0;
for(int i=1;i<=n;++i) {
for(int j=i;j<=n;++j) {
ans=max(ans,p[j]-p[i-1]-a[j].S+a[i].S);
}
}
cout<<ans<<'\n';
}
signed main() {
ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
int T=1;
//cin>>T;
while(T--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |