제출 #699739

#제출 시각아이디문제언어결과실행 시간메모리
699739Mo7amed_HossamArt Exhibition (JOI18_art)C++17
0 / 100
0 ms212 KiB
/*
* created by Mohamed hossam
 ####        ####                  ##                                                ##
 ## ##      ## ##      #####       ##         ##                  ######             ##
 ##  ##    ##  ##    ##     ##     #######    ##############     ##    ##      ########
 ##   ######   ##   ##       ##    #######    ##############    #########     ##     ##
 ##            ##    ##     ##     ##   ##    ##    ##    ##     ##           ##     ##
 ###          ###      #####       ##   ##    ##    ##    ##      #######      ########
*/
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main()
{
    fast;
    ll n;
    cin>>n;
    pair<ll,ll>a[n];
    for(ll i=0; i<n; i++)
    {
        cin>>a[i].first>>a[i].second;
    }
    /*
    1 5
    4 1
    4 2
    5 3
    9 1
    10 3
    */
    sort(a,a+n);
    ll k=0,x=-1,z=0;
    for(ll i=0; i<n; i++)
    {
        k+=a[i].second;
        x=max(x,k-(a[i].first-a[0].first));
        z=max(z,a[i].second);
    }
    k=0;
    for(ll i=n-1; i>=0; i--)
    {
        k+=a[i].second;
        x=max(x,k-(a[n-1].first-a[i].first));
    }
    cout<<max(x,z);
    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...