#include #include #include using namespace std; int L, N, Lim; int main() { cin >> L; cin >> N; vector Wi(N); for (int i = 0; i < N; i++) { cin >> Wi[i]; } //----------input---------- sort(Wi.begin(), Wi.end()); for (int i = 0; i < N; i++) { Lim += Wi[i]; if (Lim > L) { cout << i << endl; break; } else { cout << N << endl; } } return 0; }