#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY 100000000000005
#define mod 1000000007
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define lim 300005
#define fi first
#define se second
vector<pair<int,int>> dizi;
int32_t main(){
faster
int n;cin>>n;
dizi.push_back({0,0});
FOR{
int x,y;cin>>x>>y;
dizi.push_back({x,y});
}
sort(dizi.begin(),dizi.end());
int mini_bir=LLONG_MAX,cev=-LLONG_MAX,sum=0;
FOR{
sum+=dizi[i].se;
mini_bir=min(mini_bir,dizi[i].fi);
//cout<<sum<<" "<<mini_bir<<" "<<cev<<" "<<sum-(dizi[i].fi-mini_bir)<<endl;
cev=max(cev,sum-(dizi[i].fi-mini_bir));
if(sum-(dizi[i].fi-mini_bir)>0){
cev=max(cev,sum-(dizi[i].fi-mini_bir));
}
else{
sum=dizi[i].se;
mini_bir=dizi[i].fi;
}
cev=max(cev,sum-(dizi[i].fi-mini_bir));
}
cout<<cev<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |