| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1341155 | aykhn | Art Exhibition (JOI18_art) | C11 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf 0x3F3F3F3F
const int MXN = 4e5 + 5;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
array<int, 2> a[n];
for (auto &[i, j] : a) cin >> i >> j;
sort(a, a + n);
int sum = 0, res = 0;
for (auto &[x, y] : a) {
sum = max(sum + y, x + y);
res = max(res, sum - x);
}
cout << res << '\n';
}