Submission #492636

#TimeUsernameProblemLanguageResultExecution timeMemory
4926365APBali Sculptures (APIO15_sculpture)C++17
9 / 100
1096 ms320 KiB
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<set>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<queue>
#include<bitset>
 
using namespace std;
 
#pragma GCC optimize ("Ofast")

#define all(x) x.begin() , x.end()
#define MP(x , y) make_pair(x , y)
#define wall cerr<<"--------------------------------------"<<endl
#define PB(x) push_back(x)

typedef long long int ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef pair<ll , ll> pll;
typedef pair<int , int> pii;
typedef long double db;
typedef pair<pll , ll> plll;
typedef pair<int , pii> piii;
typedef pair<pll , pll> pllll;
 
const ll maxn = 1e2+5 , maxc = 1e2+5, md = 1e9 + 7 , inf = 2e16;

ll n , a , b , x[maxn]; 

ll sol(ll pos , ll use , ll st , ll sum = 0)
{
    if(pos==n){
        if(st >= a && st<= b) return use|sum;
        return inf;
    }
    sum+=x[pos];
    ll res = sol(pos+1 , use , st , sum);
    if(st < b && pos < n-1) res= min(res , sol(pos+1 , use|sum , st+1));
    return res;
}

void solve()
{
    cin>>n>>a>>b;
    for(int i = 0 ; i<n ; i++)cin>>x[i];
    cout<<sol(0 , 0 , 1)<<'\n';
    return;
}


int main()
{
	// foropen("input.txt" , "r" , stdin);
	// foropen("output.txt" , "w" , stdout);

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    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...
#Verdict Execution timeMemoryGrader output
Fetching results...