DFS + Memo + Pruning (12 ms)
This is a multi-knapsack problem, which is very tough. Fortunately, it\u2019s constrained to 14 tasks. We won\u2019t have more than 14 sessions - each up to 15 
This is a multi-knapsack problem, which is very tough. Fortunately, it\u2019s constrained to 14 tasks. We won\u2019t have more than 14 sessions - each up to 15 hours long. Therefore, we can represent the sessions state using 64-bit.\n\nThe most important optimization is to sort sessions before computing the state. The order of sessions does not matter - it only matters how long they are.\n\nTo speed it up even more, we can prune our search if it exceeds some number of sessions (which we can find greedily).\n\n**C++**\n```cpp\nunordered_map<long long, int> m;\nint dfs(vector<int>& tasks, vector<int> rem, int sessionTime, int i, int lim) {\n    if (i >= tasks.size())\n        return 0;\n    if (rem.size() > lim)\n        return 1000;\n    long long cache = 0;\n    sort(begin(rem), end(rem));\n    for (auto r : rem)\n        cache = (cache << 4) + r + 1;\n    if (m.count(cache))\n        return m[cache];\n    rem.push_back(sessionTime - tasks[i]);\n    int res = 1 + dfs(tasks, rem, sessionTime, i + 1, lim);\n    rem.pop_back();\n    for (int j = 0; j < rem.size(); ++j) {\n        if (rem[j] >= tasks[i]) {\n            rem[j] -= tasks[i];\n            res = min(res, dfs(tasks, rem, sessionTime, i + 1, lim));\n            rem[j] += tasks[i];\n        }\n    }\n    return m[cache] = res;\n}\nint greedy(vector<int>& tasks, int sessionTime) {\n    vector<int> sessions;\n    for (int t : tasks) {\n        bool found = false;\n        for (int i = 0; !found && i < sessions.size(); ++i) {\n            if (sessions[i] >= t) {\n                sessions[i] -= t;\n                found = true;\n            }\n        }\n        if (!found)\n            sessions.push_back(sessionTime - t);\n    }\n    return sessions.size();\n}\nint minSessions(vector<int>& tasks, int sessionTime) {\n    sort(begin(tasks), end(tasks), greater<int>());\n    return dfs(tasks, vector<int>() = {}, sessionTime, 0, greedy(tasks, sessionTime));\n}\n```
['C']