#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
#include<set>
#include<map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define st first
#define nd second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long lo;
const int mod=1000000007,N=500005;
lo a,b,c,d,e,f,g=1,h[N];
pair<lo,lo> arr[N];
string s;
vector<lo>v;
void solve(){
cin >> a;
for(lo i=1;i<=a;i++){
cin >> arr[i].st >> arr[i].nd;
}
sort(arr+1,arr+a+1);
lo sum=arr[1].nd,ans=0;
for(lo i=2;i<=a;i++){
sum+=arr[i].nd-(arr[i].st-arr[i-1].st);
ans=max(ans,sum);
if(sum<0)sum=0;
}
cout << ans << endl;
}
int main(){
// #ifdef local
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
// #endif
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
// cin >> g;
while(g--)solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |