Submission #1345191

#TimeUsernameProblemLanguageResultExecution timeMemory
1345191vjudge1Art Exhibition (JOI18_art)C++17
100 / 100
299 ms8240 KiB
/*
???????  ?????? ???????????  ?????????????
???????????????????????????  ??????????????
??????????????????????????????????????   ???
??????????????????????????????????????   ???
???  ??????  ??????????????  ??????????????
???  ??????  ??????????????  ?????????????
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define ull unsigned long long
#define ld long double
#define str string
#define ch char
#define db double
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define Bob cout<<"Bob\n";
#define Alice cout<<"Alice\n";
#define ordered_set tree<pair<ll, ll>, null_type,less<pair<ll,ll>>,rb_tree_tag,tree_order_statistics_node_update>
const ll MOD=12345;
const ll INF = 10000000000;
void basibatmis(__int128 n){
    if(n==0){
        cout<<"0";
        return;
    }
    str s = "";
    while(n>0){
        s+=(ch)('0'+n%10);
        n/=10;
    }
    reverse(all(s));
    cout<<s;
}
void solve(){
    ll n;
    cin>>n;
    vector<pair<ll,ll>>v(n);
    for(int i = 0;i<n;i++){
        cin>>v[i].ff>>v[i].ss;
    }
    sort(all(v));
    ll mx=0;
    ll sum=0;
    ll kh = -INF;
    for(int i = 0;i<n;i++){
        ll alma = v[i].ff;
        ll armud = v[i].ss;
        kh = max(kh,alma-sum);
        sum+=armud;
        mx=max(mx,sum-alma+kh);
    }
    cout<<mx;
}
signed main(){
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...