# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
60399 | gusfring | Art Exhibition (JOI18_art) | C++14 | 2 ms | 248 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
typedef long long ll;
#define sz first
#define val second
pair<ll, ll> C[MAXN];
ll suf[MAXN], pre[MAXN], res;
int N;
int main(){
scanf("%d", &N);
for(int i=1; i<=N; ++i) scanf("%lld %lld", &C[i].sz, &C[i].val);
sort(C + 1, C + N + 1);
for(int i=1; i<=N; ++i) pre[i] = pre[i - 1] + C[i].val;
for(int i=N; i>=1; --i) suf[i] = max(suf[i + 1], pre[i] - C[i].sz);
for(int i=1; i<=N; ++i) res = max(res, suf[i] - pre[i - 1] + C[i].sz);
printf("%lld\n", res);
return 0;
}
컴파일 시 표준 에러 (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... |