Company: Edelweiss
Difficulty: medium
Minimize Cost of Task Scheduling The data analysts of Hackerland want to schedule some long-running tasks on remote servers optimally to minimize the cost of running them locally. The analysts have two servers, a paid one and a free one. The free server can be used only if the paid server is occupied. The i th task is expected to take time[i] units of time to complete and the cost of processing the task on the paid server is cost[i] . The task can be run on the free server only if some task is already running on the paid server. The cost of the free server is 0, and it can process any task in 1 unit of time. Find the minimum cost to complete all the tasks if tasks are scheduled optimally. Input Format The first line contains an integer n , the number of tasks. The second line contains n space-separated integers representing cost , where cost[i] is the cost of scheduling the i-th task on the paid server. The third line contains n space-separated integers representing time , where time[i