hiho week 184 register

Ended

Participants:252

Verdict:Accepted
Score:100 / 100
Submitted:2018-01-08 20:47:19

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<bits/stdc++.h>
using namespace std;
int n, x ,a[110],sum;
void dfs(int i, int count)
{
    if(i > n)
        return;
    if(count >= x)
    {
        if(count<sum)
            sum = count;
        return;
    }
    dfs(i+1,count+a[i]);
    dfs(i+1,count);
}
int main()
{   
    sum = 0;
    cin>>n>>x;
    for(int i = 0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum<x)
    {
        cout<<-1<<endl;
        return 0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX