蒟蒻只会搜。。。样例都过不去
想了半天没看出来哪错了
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int V,n,vi[39];
int dfs(int begin, int rest) {
if (rest <= 0) return 0;
if (begin == n) {
if (rest >= vi[begin]) return rest - vi[begin];
else return rest;
}
if (rest >= vi[begin]) {
return f(begin+1, rest-vi[begin]);
} else return f(begin+1, rest);
}
int main(void) {
cin>>V>>n;
for (int i=1; i<=n; i++) cin>>vi[i];
cout<<dfs(1, V);
return 0;
}