# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45661 | reality | Art Exhibition (JOI18_art) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void) {
int n;
cin>>n;
map < ll , ll > M;
for (auto & it : s) {
ll u,v;
cin>>u>>v;
M[u] += v;
}
vector < pair < ll , ll > > s;
for (auto it : M)
s.pb(it);
vl ss;
for (int i = 1;i < n;++i)
s[i].se += s[i - 1].se;
ll mn = -s[0].fi;
ll ans = -1e18;
for (int i = 1;i < n;++i) {
smax(ans,s[i].se - s[i].fi - mn);
smin(mn,s[i - 1].se - s[i].fi);
}
cout << ans << '\n';
return 0;
}