이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* Martin Leshko (leshko.martin@gmail.com)
*/
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define sz(a) (int)a.size()
const int N = 300001;
int main() {
ios::sync_with_stdio(false), cin.tie(0);
int n;
cin >> n;
vector< pair<long long, long long> > a(n);
for (int i = 0; i < n; i++) {
long long x, y;
cin >> x >> y;
a[i] = {x, y};
}
sort(a.begin(), a.end());
long long prefix = 0, mn = 0x3f3f3f3f3f3f3f3f, ans = -0x3f3f3f3f3f3f3f3f;
for (int i = 0; i < n; i++) {
prefix += a[i].second;
mn = min(mn, prefix - a[i].second - a[i].first);
ans = max(ans, prefix - a[i].first - mn);
}
cout << ans << 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... |