제출 #699379

#제출 시각아이디문제언어결과실행 시간메모리
699379Mo7amed_HossamArt Exhibition (JOI18_art)C++17
10 / 100
1091 ms340 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=-1e18;
void solve(ll i,ll sum,ll max1,ll min1)
{

    if(i==n&&max1!=-1e18&&min1!=1e18){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,-1e18,1e18);
    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...