Abaka.aiOA #1
Task Scheduling (Parallel Same-Type with Memory Limit)
Estimated MediumJudge-ready
Topics (AI-labelled)GreedyTwo PointersHashing
Each task takes 1 unit of time. Two tasks can be processed in parallel if and only if they have the same type and their total memory is ≤maxMemory; every other task is processed alone. Find the minimum total processing time.
Input
The input contains N, maxMemory, N values of taskMemory, and N values of taskType. 1≤N≤200000, 1≤taskMemory[i]≤maxMemory≤10^9, 1≤taskType[i]≤10^9. This site specifies that every task can run alone, even if its memory does not allow it to run in parallel with another task.
Output
Output the minimum number of time units.
Example 1
Input:
4 10
7 2 3 9
1 2 1 3
Output:
3
Example 2
Input:
3 10
5 5 5
1 1 1
Output:
2
Example 3
Input:
2 10
2 9
3 3
Output:
2
Editorial
Loading solution…