#include #include #include using namespace std; int main() { double BoxWidth; int NumberOfBlocks; vector BlockWidths; cin >> BoxWidth >> NumberOfBlocks; for (auto i = 0; i != NumberOfBlocks; ++i) { double w; cin >> w; BlockWidths.push_back(w); } sort(BlockWidths.begin(), BlockWidths.end()); double BockWidthAmount(0); int i(0); for (; i != NumberOfBlocks; ++i) { BockWidthAmount += BlockWidths.at(i); if (BockWidthAmount > BoxWidth) break; } cout << i << endl; return 0; }