제출 #699378

#제출 시각아이디문제언어결과실행 시간메모리
699378Mo7amed_HossamArt Exhibition (JOI18_art)C++17
0 / 100
1 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;
ll n;
pair<ll,ll>a[5001];
ll p=-1e5;
void solve(ll i,ll sum,ll max1,ll min1)
{
    
    if(i==n&&max1!=-1e9&&min1!=1e9){p=max(p,sum-(max1-min1));return;}if(i>=n)return;
    solve(i+1,sum,max1,min1);
    solve(i+1,sum+a[i].second,max(max1,a[i].first),min(a[i].first,min1));
}
int main()
{
    fast;

    cin>>n;
    for(ll i=0; i<n; i++)
    {
        cin>>a[i].first>>a[i].second;
    }
    solve(0,0,-1e9,1e9);
    cout<<p;
    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...