/* * 733_sample.cpp * * No.733 分身並列コーディング */ #include #include using V = std::vector; int pattern(const V& times, const int& time, const int& num, const int& first) { auto times2 = times; for (auto i = first; i < num-1; i++) { for (auto j = i+1; j < num; j++) { if (times2[j] > 0) { auto tmp = times2[i] + times2[j]; if (time >= tmp) { times2[i] = tmp; times2[j] = -1; } } } } auto count = 0; for (auto i = 0; i < num; i++) { if (times2[i] > 0) { count++; } } return count; } int main () { auto time = 0; auto num = 0; std::cin >> time >> num; V times(num); for (auto i = 0; i < num; i++) { std::cin >> times[i]; } int ans = num; for (auto i = 0; i < num-1; i++) { auto count = pattern(times, time, num, i); if (ans > count) { ans = count; } } std::cout << ans << std::endl; return 0; }