#include using namespace std; int main(){ int l,n, i, j, tmp; cin >> l >> n; int w[n]; for(i=0;i> w[i]; } //sort for(i=0; ii;j--){ if(w[i] > w[j]){ tmp = w[i]; w[i] = w[j]; w[j] = tmp; } } } int sum = 0; i = 0; while(1){ sum += w[i]; if(l > sum) i++; else break; } cout << i << endl; return 0; }