[LeetCode] Find Minimum Time to Finish All Jobs II

2323. Find Minimum Time to Finish All Jobs II

You are given two 0-indexed integer arrays jobs and workers of equal length, where jobs[i] is the amount of time needed to complete the ith job, and workers[j] is the amount of time the jth worker can work each day.

Each job should be assigned to exactly one worker, such that each worker completes exactly one job.

Return the minimum number of days needed to complete all the jobs after assignment.

1
2
3
4
5
6
7
8
9
10
11
12
13
class Solution {
public:
int minimumTime(vector<int>& A, vector<int>& B) {
sort(begin(A), end(A));
sort(begin(B), end(B));
int n = A.size(), res = 0;
for(int i = 0; i < n; i++) {
int t = ceil(1.0 * A[i] / B[i]);
res = max(res,t);
}
return res;
}
};
Author: Song Hayoung
Link: https://songhayoung.github.io/2022/07/03/PS/LeetCode/find-minimum-time-to-finish-all-jobs-ii/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.