背包
#includeusing namespace std;int F[1000005];int main(){ int V,q; scanf("%d%d",&V,&q); F[0]=1; while (q--){ int x; scanf("%d",&x); for (int i=V; i>=x; i--) F[i]|=F[i-x]; } for (int i=V; i>=0; i--) if (F[i]){ printf("%d\n",i); return 0; } return 0;}