#include #include #include using namespace std; template inline bool chmin(t& a, t b) { if (a > b) { a = b; return 1; } return 0; } template T ceil(T a, T b) { return a / b + !!(a % b); } int main() { int T, n; cin >> T >> n; vector t(n); for (auto &ti: t) cin >> ti; vector dp(1 << n, T * n); dp[0] = 0; for (int mask = 0; mask < 1 << n; mask++) { int rem = T - dp[mask] % T; for (int i = 0; i < n; i++) if (!(mask >> i & 1)) { int add = t[i] <= rem ? t[i] : rem + t[i]; chmin(dp[mask ^ (1 << i)], dp[mask] + add); } } cout << ceil(dp[(1 << n) - 1], T) << endl; return 0; }