#include <bits/stdc++.h>
#include <sstream>
using namespace std;
#define accepted ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define Daulbekov signed
#define Makan main
#define int long long
#define double long double
#define pb push_back
#define pf push_front
#define F first
#define S second
const int N=1e5+7;
const int MAX=9e18+7;
const int INF=1e18;
Daulbekov Makan(){
int n;
cin>>n;
pair<int,int>a[n];
int vozmozhno=0;
for(int i=0;i<n;i++){
cin>>a[i].F>>a[i].S;
vozmozhno=max(vozmozhno,a[i].S);
}
sort(a,a+n);
int mx=a[0].S,col=a[0].S;
bool b=1;
for(int i=1;i<n;i++){
if(b==0){
b=1;
col+=a[i].S;
mx=max(mx,col);
continue;
}
col+=a[i].S;
col-=(a[i].F-a[i-1].F);
if(col<0){
col=0;
b=0;
}
if(col<a[i].S)col=a[i].S;
mx=max(mx,col);
}
cout<<max(mx,vozmozhno);
}
// 2 3
// 4 5
// 11 2
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |