Minimum Time to Process Tasks

Company: Ion group_26july

Difficulty: medium

Problem Statement

Minimum Time to Process Tasks Problem Description A server must process n tasks. Task i requires taskMemory[i] units of memory and has a type given by taskType[i] . Every task takes exactly 1 unit of time to process, and every task must be processed. The server can process at most two tasks at the same time , and it may do so only when both of the following hold for that pair of tasks: the two tasks have the same type , and their combined memory requirement is no more than maxMemory . Two tasks processed together still take 1 unit of time in total. Every task that is not paired with another task is processed on its own and takes 1 unit of time. Given taskMemory , taskType and maxMemory , return the minimum total time required to process all n tasks. Input Format The first line contains an integer, n , the number of elements in taskMemory . The following n lines each contain an integer, taskMemory[i] . The next line contains an integer, n , the number of elements in taskType . This valu