| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1316083 | ttamx | Art Exhibition (JOI18_art) | C11 | 0 ms | 0 KiB |
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N=5e5+5;
int n;
pair<ll,ll> a[N];
ll ans=0;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n;
for(int i=1;i<=n;i++){
cin >> a[i].first >> a[i].second;
}
sort(a+1,a+n+1);
for(int i=1;i<=n;i++){
ll sum=0;
for(int j=i;j<=n;j++){
sum+=a[j].second;
ans=max(ans,sum-(a[j].first-a[i].first));
}
}
cout << ans << "\n";
}
