제출 #1033961

#제출 시각아이디문제언어결과실행 시간메모리
1033961vjudge1Art Exhibition (JOI18_art)C++17
100 / 100
139 ms8284 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pf push_front
#define fi first
#define se second
const ll mod = 1e9+7;
signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // freopen("test.inp","r",stdin); freopen("test.out","w",stdout); freopen("test.err","w",stderr);
    ll n, opt = 1e18, ans = -1e18; cin >> n;
    vector<pair<ll,ll>> v(n+1); v[0].fi = v[0].se = 0;
    for (ll i = 1; i <= n; i++) cin >> v[i].fi >> v[i].se;
    sort(v.begin()+1,v.end());
    for (ll i = 1; i <= n; i++) v[i].se += v[i-1].se;
    for (ll i = 1; i <= n; i++) 
    {
        opt = min(opt, v[i-1].se-v[i].fi);
        ans = max(ans, v[i].se-v[i].fi-opt);
    }
    cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...