# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
163182 | fenech20 | Art Exhibition (JOI18_art) | C++14 | 391 ms | 20984 KiB |
이 제출은 이전 버전의 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()
typedef long long ll;
int main() {
ll n;
scanf("%lld", &n);
vector<pair<ll, ll> > a(n);
for (int i = 0; i < n; i++) {
scanf("%lld%lld", &a[i].first, &a[i].second);
}
sort(a.begin(), a.end());
ll prefix = 0, ans = -0x3f33f3f3f3f3f, mn = 0x3f3f3f3f3f3f;
for (int i = 0; i < n; i++) {
mn = min(mn, prefix - a[i].first);
prefix += a[i].second;
ans = max(ans, prefix - mn - a[i].first);
// fprintf(stderr, "mn = %d, prefix = %d, ans = %d\n", mn, prefix, ans);
}
printf("%lld", ans);
}
//
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |