class Solution {
public:
int minProcessingTime(vector<int>& processorTime, vector<int>& tasks) {
int ans = 0;
sort(processorTime.begin(), processorTime.end());
sort(tasks.rbegin(), tasks.rend());
// It's optimal to run each 4 longer tasks with smaller processor time.
// Therefore, for each processor, take the maximum of the sum of the
// processor time and the largest assigned tasks[i].
for (int i = 0; i < processorTime.size(); ++i)
ans = max(ans, processorTime[i] + tasks[i * 4]);
return ans;
}
};