hiho week 184 register

Ended

Participants:252

Verdict:Accepted
Score:100 / 100
Submitted:2018-01-09 14:13:10

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 <cstdlib>
#include <cstring>
using namespace std;
const int maxn = 201;
 
int n,x,dp[maxn]; 
 
int main(){
    
    int i,j,ans,  num[maxn];
    while(scanf("%d %d", &n, &x) != EOF){
        for(i=0; i<n; i++){
            scanf("%d", &num[i]);
        }
        memset(dp, 0, sizeof(dp));
        dp[0] = 1;
        for(i=0; i<n; i++){
            for(j=maxn-1; j>=num[i]; j--){
                if(dp[j-num[i]]){
                    dp[j] = 1;
                }
            }
        }
        int ans=-1;
        for(i=x; i<maxn; i++){
            if(dp[i]){
                ans=i;
                break;
            }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX