# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
108779 | thebes | Art Exhibition (JOI18_art) | C++14 | 281 ms | 24824 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MN = 5e5+5;
typedef long long ll;
ll psa[MN], n, i, x, y, ans, mx;
pair<ll,ll> arr[MN];
int main(){
for(scanf("%lld",&n),i=1;i<=n;i++){
scanf("%lld%lld",&arr[i].first,&arr[i].second);
}
sort(arr+1,arr+n+1,[](pair<ll,ll>i,pair<ll,ll>j){return i.first<j.first;});
for(i=1;i<=n;i++){
psa[i]=psa[i-1]+arr[i].second-(arr[i].first-arr[i-1].first);
}
mx = -1LL<<60; ans = -1LL<<60;
for(i=n;i>=1;i--){
mx = max(mx, psa[i]);
ans = max(ans, mx-psa[i-1]+arr[i].first-arr[i-1].first);
}
printf("%lld\n",ans);
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... |