# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
465911 | dattranxxx | Art Exhibition (JOI18_art) | C++11 | 260 ms | 24812 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
* Author : shora
*/
#include <bits/stdc++.h>
#define print(_v) for (auto &_ : _v) {cerr << _ << ' ';} cerr << endl;
using namespace std;
using ll = long long;
const ll oo = 1e18;
const int N = 5e5;
struct P {
int v = 0;
ll w = 0, f = 0;
bool operator < (const P& p) {
return w < p.w;
}
};
P a[N+1];
int n;
int main() {
cin.tie(0)->sync_with_stdio(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i].w >> a[i].v;
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; ++i)
a[i].f = a[i-1].f + a[i].v;
ll res = -oo, mx = -oo;
// a[r].f - a[l-1].f - a[r].w + a[l].w
// a[r].f - a[r].w + (a[l].w - a[l-1].f)
for (int r = 1; r <= n; ++r) {
mx = max(mx, a[r].w - a[r-1].f);
res = max(res, a[r].f - a[r].w + mx);
}
cout << 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... |