as

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
553 B
3
Indexable
Never
#include<bits/stdc++.h>
using namespace std;

int minTime(vector<int> processorTime, vector<int> taskTime){
  sort(processorTime.begin(), processorTime.end());
  sort(taskTime.begin(), taskTime.end());
  reverse(taskTime.begin(), taskTime.end());
  int ans = 0;
  int curTask = 0;
  for(int proctime : processorTime){
    for(int i = 0; i <4 ; ++i){
        int completionTime = taskTime[curTask] + proctime;
        curTask++;
        ans = max(ans, completionTime);
    }
  }
  return ans;
}

int main(){
  cout << minTime({8,10},{2,2,3,1,8,7,4,5});
}