OJ-Problems-Source/CodeVS/1014_冰封.c

25 lines
456 B
C
Raw Normal View History

2016-07-06 14:28:18 +08:00
/*
:
:p1014
*/
int i, v, max = 0, a[35], n;
#include<stdio.h>
#include<memory.h>
void dfs(int idx, int size){
if(size >= v) return ;
max = max > size ? max : size;
if(idx >= n - 1) return ;
idx++;
dfs(idx, size);
dfs(idx, size + a[idx]);
}
int main(){
scanf("%i%i", &v, &n);
for(i = 0; i < n; i++)
scanf("%i", &a[i]);
dfs(-1, 0);
printf("%i", v - max);
return 0;
}