#include #include #include #include using namespace std; int main(){ int l, n, i, w, count = 0; vector w_v; cin >> l >> n; for (i = 0;i> w; w_v.push_back(w); } sort(w_v.begin(),w_v.end()); i = 0; for (i = 0;i < n;i++){ if (l - w_v[i] < 0){ break; } l = l - w_v[i]; count++; i++; } cout << count << endl; }