#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define task "code"
const int ar=5e5+5;
const ll mod=1e9+7;
int n;
pair<ll,int> a[ar];
ll ans=-1e18;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
// if (fopen(task".inp","r"))
// {
// freopen(task".inp","r",stdin);
// freopen(task".out","w",stdout);
// }
cin>>n;
for (int i=1;i<=n;i++)
{
cin>>a[i].fi>>a[i].se;
}
sort(a+1,a+n+1);
ll ma=0;
for (int i=1;i<=n;i++)
{
if (i==1)
{
ma+=a[i].fi;
ma+=a[i].se;
}
else
{
ma+=a[i].se;
}
ans=max(ans,ma-a[i].fi);
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |