#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N=5e5+5;
int const mod=1e9+7;
pair<int,int> arr[N];
ll largest_subarray_sum(vector<int> v, int n){
ll ans=0;
ll cur=0;
for(int i=0;i<n;i++){
if(cur+v[i]>=0)
cur+=v[i];
else
cur=0;
ans=max(ans,cur);
}
return ans;
}
void solve(){
int n;
cin>>n;
for (int i = 0; i < n; ++i)
cin>>arr[i].first>>arr[i].second;
sort(arr,arr+n);
vector<int> v;
for(int i=0;i<n-1;i++){
v.push_back(arr[i].second);
v.push_back(arr[i].first-arr[i+1].first);
}
v.push_back(arr[n-1].second);
cout<<largest_subarray_sum(v,2*n-1)<<endl;
}
int main(){
int t=1;
// cin>>t;
while(t--)
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
- |