# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
122748 | arnold518 | Art Exhibition (JOI18_art) | C++14 | 274 ms | 26848 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 5e5;
struct Art
{
ll a, b, d;
};
int n;
Art arr[MAXN+10];
ll ans;
int main()
{
int i, j;
scanf("%d", &n);
for(i=1; i<=n; i++) scanf("%lld%lld", &arr[i].a, &arr[i].b);
sort(arr+1, arr+n+1, [&](Art p, Art q) { return p.a<q.a; });
for(i=1; i<=n; i++) arr[i].b+=arr[i-1].b, arr[i].d=arr[i].b-arr[i].a;
vector<int> S;
for(i=n; i>=1; i--)
{
if(S.empty() || arr[S.back()].d<arr[i].d) S.push_back(i);
}
for(i=1; i<=n; i++)
{
ans=max(ans, arr[i].a+arr[S.back()].d-arr[i-1].b);
if(S.back()==i) S.pop_back();
}
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... |