제출 #654148

#제출 시각아이디문제언어결과실행 시간메모리
654148lunchbox1Art Exhibition (JOI18_art)C++17
100 / 100
185 ms20688 KiB
/*
 author: lunchbox
 problem link: https://oj.uz/problem/view/JOI18_art
*/
#include <bits/stdc++.h>
using namespace std;

int main() {
 ios::sync_with_stdio(0), cin.tie(0);
 int n; cin >> n;
 vector<pair<long long, int>> a(n);
 for (auto &[x, y] : a) cin >> x >> y;
 sort(a.begin(), a.end());
 long long ans = 0, pre = 1e18, cur = 0;
 for (auto [x, y] : a) {
  pre = min(pre, cur - x);
  ans = max(ans, cur - x + y - pre), cur += y;
 }
 cout << ans << '\n';
 return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...