hiho week 184 register

Ended

Participants:252

Verdict:Accepted
Score:100 / 100
Submitted:2018-01-10 20:30:56

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<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int a[100];
int dp[2001];
int main()
{
    int N,X;
    int sum=0;
    scanf("%d %d",&N,&X);
    for(int i=0;i<N;i++)
    {
         scanf("%d",&a[i]);
         sum+=a[i];
    }
    int up=sum-X;
    if(up<0)
        printf("%d\n",-1);
    else if(up==0)
        printf("%d\n",X);
    else
    {
        memset(dp,0,sizeof(dp));
        int maxn=-1;
        for(int i=0;i<N;i++)
            for(int j=up;j>0;j--)
            {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX