# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
701317 | Zezo_Amr | Art Exhibition (JOI18_art) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
vector<pair<int,int>>v2;
for(int i=0; i<n; i++)
{
double long x,y;
cin>>x>>y;
v.push_back({x,y});
v2.push_back({y-x,i});
}
sort(v2.begin(),v2.end(),greater<pair<int,int>>());
int c,mxm=-10000000000000000,s=0,mx=-10000000000000000,mn=10000000000000000;
for(int i=0; i<n; i++)
{
int x=v2[i].second;
s+=v[x].second;
mx=max(mx,v[x].first);
mn=min(mn,v[x].first);
c=s-(mx-mn);
if(c>mxm)
{
mxm=c;
}
}
cout<<mxm<<'\n';
return 0;
}