hiho week 184 register

Ended

Participants:252

Verdict:Accepted
Score:100 / 100
Submitted:2018-01-11 15:22:30

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
#include <cstdio>
using namespace std;
int n,x,t;
bool check[1005];
int main()
{
    scanf("%d%d",&n,&x);
    check[0]=1;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&t);
        for(int j=500;j>=0;j--)
            if(check[j])check[j+t]=1;
    }
    for(int i=x;i<=490;i++)
    {
        if(check[i])
        {
            printf("%d\n",i);
            return 0;
        }
    }
    printf("-1\n");
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX