[Offer收割]编程练习赛4 register

Ended

Participants:899

Verdict:Accepted
Score:100 / 100
Submitted:2016-08-07 12:10:27

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 <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
using namespace std;
int N,X,a[30],t,m=1e5;
void dfs(int i){
if(t>=X&&t<m)
m=t;
if(t>=m)
return;
if(i>N)
return;
t=t+a[i];
dfs(i+1);
t=t-a[i];
dfs(i+1);
}
int main(){
int i,j,k;
scanf("%d%d",&N,&X);
for(i=1;i<=N;i++)
scanf("%d",a+i);
t=0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX