# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
47013 | leejseo | Art Exhibition (JOI18_art) | C++17 | 326 ms | 20436 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <utility>
#include <algorithm>
#include <vector>
using namespace std;
#define MAXN 500002
typedef long long lld;
typedef pair<lld, lld> pll;
lld S[MAXN], X[MAXN], Y[MAXN], ans;
vector<pll> U;
int N;
int main(void){
scanf("%d", &N);
lld a, b;
for (int i=0; i<N; i++){
scanf("%lld%lld", &a, &b);
U.push_back(make_pair(a, b));
}
sort(U.begin(), U.end());
for (int i=0; i<N; i++){
S[i+1] = S[i] + U[i].second;
}
Y[0] = -(U[0].first);
for (int i=1; i<=N; i++){
X[i] = S[i] - U[i-1].first;
if (i != N) Y[i] = min(Y[i-1], S[i]-U[i].first);
}
for (int i=0; i<N; i++) ans = max(ans, X[i+1]-Y[i]);
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... |