이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using pll = pair<i64, i64>;
vector<pll> v;
int n;
int main() {
#ifdef HOME
freopen("joi_art.in", "r", stdin);
freopen("joi_art.out", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
i64 sum = 0, best = -1e18, ant = 0;
cin >> n;
v.resize(n);
for (auto &i: v)
cin >> i.first >> i.second;
sort(begin(v), end(v));
for (auto i: v) {
best = max(best, i.first - sum);
sum+= i.second;
ant = max(ant, sum - i.first + best); }
cout << ant << endl;
return 0; }
# | 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... |