이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
freopen("in", "r", stdin);
#endif
int n; cin >> n;
vector<ii> p(n);
for(int i = 0; i < n; i++) {
cin >> p[i].first >> p[i].second;
}
sort(p.begin(), p.end());
for(int i = 1; i < n; i++)
p[i].second += p[i - 1].second;
ll cmx = p[0].first, Max = p[0].second;
for(int i = 1; i < n; i++) {
Max = max(Max, p[i].second - p[i].first + cmx);
cmx = max(cmx, p[i].first - p[i - 1].second);
}
cout << Max << endl;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |