#include #include #include #include using namespace std; int main() { int max_width, num, width; vector vt; cin >> max_width; cin >> num; while (num--) { int temp; cin >> temp; vt.push_back(temp); } sort(vt.begin(), vt.end()); for (int cnt = 0; cnt <= num; cnt++) { max_width -= vt[cnt]; if ((max_width<=0) || (cnt == num-1)) { printf("%d\n", ++cnt); break; } } return 0; }