Algorithms
Medium
2895
3151
Minimum Processing Time
minimum-processing-time
"""
You have n processors each having 4 cores and n * 4 tasks that need to be executed such that each core should perform only one task.

Given a 0-indexed integer array processorTime representing the time at which each processor becomes available for the first time and a 0-indexed integer array tasks representing the time it takes to execute each task, return the minimum time when all of the tasks have been executed by the processors.

Note: Each core executes the task independently of the others.

Example 1:

Input: processorTime = [8,10], tasks = [2,2,3,1,8,7,4,5]
Output: 16
Explanation:
It's optimal to assign the tasks at indexes 4, 5, 6, 7 to the first processor which becomes available at time = 8, and the tasks at indexes 0, 1, 2, 3 to the second processor which becomes available at time = 10.
Time taken by the first processor to finish execution of all tasks = max(8 + 8, 8 + 7, 8 + 4, 8 + 5) = 16.
Time taken by the second processor to finish execution of all tasks = max(10 + 2, 10 + 2, 10 + 3, 10 + 1) = 13.
Hence, it can be shown that the minimum time taken to execute all the tasks is 16.

Example 2:

Input: processorTime = [10,20], tasks = [2,3,1,2,5,8,4,3]
Output: 23
Explanation:
It's optimal to assign the tasks at indexes 1, 4, 5, 6 to the first processor which becomes available at time = 10, and the tasks at indexes 0, 2, 3, 7 to the second processor which becomes available at time = 20.
Time taken by the first processor to finish execution of all tasks = max(10 + 3, 10 + 5, 10 + 8, 10 + 4) = 18.
Time taken by the second processor to finish execution of all tasks = max(20 + 2, 20 + 1, 20 + 2, 20 + 3) = 23.
Hence, it can be shown that the minimum time taken to execute all the tasks is 23.


Constraints:

 * 1 <= n == processorTime.length <= 25000
 * 1 <= tasks.length <= 105
 * 0 <= processorTime[i] <= 109
 * 1 <= tasks[i] <= 109
 * tasks.length == 4 * n
"""
class Solution:
    def minProcessingTime(self, processorTime: List[int], tasks: List[int]) -> int:
        
You have n processors each having 4 cores and n * 4 tasks that need to be executed such that each core should perform only one task.

Given a 0-indexed integer array processorTime representing the time at which each processor becomes available for the first time and a 0-indexed integer array tasks representing the time it takes to execute each task, return the minimum time when all of the tasks have been executed by the processors.

Note: Each core executes the task independently of the others.

Example 1:

Input: processorTime = [8,10], tasks = [2,2,3,1,8,7,4,5]
Output: 16
Explanation:
It's optimal to assign the tasks at indexes 4, 5, 6, 7 to the first processor which becomes available at time = 8, and the tasks at indexes 0, 1, 2, 3 to the second processor which becomes available at time = 10.
Time taken by the first processor to finish execution of all tasks = max(8 + 8, 8 + 7, 8 + 4, 8 + 5) = 16.
Time taken by the second processor to finish execution of all tasks = max(10 + 2, 10 + 2, 10 + 3, 10 + 1) = 13.
Hence, it can be shown that the minimum time taken to execute all the tasks is 16.

Example 2:

Input: processorTime = [10,20], tasks = [2,3,1,2,5,8,4,3]
Output: 23
Explanation:
It's optimal to assign the tasks at indexes 1, 4, 5, 6 to the first processor which becomes available at time = 10, and the tasks at indexes 0, 2, 3, 7 to the second processor which becomes available at time = 20.
Time taken by the first processor to finish execution of all tasks = max(10 + 3, 10 + 5, 10 + 8, 10 + 4) = 18.
Time taken by the second processor to finish execution of all tasks = max(20 + 2, 20 + 1, 20 + 2, 20 + 3) = 23.
Hence, it can be shown that the minimum time taken to execute all the tasks is 23.


Constraints:

 * 1 <= n == processorTime.length <= 25000
 * 1 <= tasks.length <= 105
 * 0 <= processorTime[i] <= 109
 * 1 <= tasks[i] <= 109
 * tasks.length == 4 * n


Please complete the code below to solve above prblem:
```python
class Solution:
    def minProcessingTime(self, processorTime: List[int], tasks: List[int]) -> int:
        
```

my_solution = Solution()

test_input = { "processorTime": [8,10], "tasks": [2,2,3,1,8,7,4,5] }
assert my_solution.minProcessingTime(**test_input) == 16

test_input = { "processorTime": [10,20], "tasks": [2,3,1,2,5,8,4,3] }
assert my_solution.minProcessingTime(**test_input) == 23

test_input = { "processorTime": [121,99], "tasks": [287,315,293,260,333,362,69,233] }
assert my_solution.minProcessingTime(**test_input) == 461

test_input = { "processorTime": [33,320], "tasks": [132,68,232,166,30,300,112,138] }
assert my_solution.minProcessingTime(**test_input) == 452

test_input = { "processorTime": [50,82], "tasks": [288,138,205,295,367,100,258,308] }
assert my_solution.minProcessingTime(**test_input) == 417

test_input = { "processorTime": [291], "tasks": [125,169,269,32] }
assert my_solution.minProcessingTime(**test_input) == 560

test_input = { "processorTime": [55,350,166,210,389], "tasks": [276,253,157,237,92,396,331,19,82,301,136,396,251,92,280,70,253,47,81,84] }
assert my_solution.minProcessingTime(**test_input) == 470

test_input = { "processorTime": [143,228,349,231,392], "tasks": [102,365,363,211,38,96,98,79,365,289,252,201,259,346,21,68,128,56,167,183] }
assert my_solution.minProcessingTime(**test_input) == 517

test_input = { "processorTime": [168,32,299,303,96], "tasks": [382,183,337,73,115,350,6,18,93,238,102,302,96,381,327,385,387,288,138,83] }
assert my_solution.minProcessingTime(**test_input) == 456

test_input = { "processorTime": [324,117,374,219,303], "tasks": [374,202,328,11,353,208,383,287,107,236,226,387,21,183,352,164,207,182,15,65] }
assert my_solution.minProcessingTime(**test_input) == 571

test_input = { "processorTime": [376], "tasks": [21,247,274,38] }
assert my_solution.minProcessingTime(**test_input) == 650

test_input = { "processorTime": [93,3,281,218], "tasks": [182,16,241,312,81,339,207,330,306,166,82,290,7,317,396,389] }
assert my_solution.minProcessingTime(**test_input) == 459

test_input = { "processorTime": [374,250,197,170], "tasks": [247,56,330,361,240,261,67,65,138,181,308,26,59,150,137,244] }
assert my_solution.minProcessingTime(**test_input) == 531

test_input = { "processorTime": [115,271,137], "tasks": [34,72,328,312,159,32,283,6,234,280,46,349] }
assert my_solution.minProcessingTime(**test_input) == 464

test_input = { "processorTime": [47,217,349,233,283], "tasks": [195,188,181,259,145,96,298,322,213,154,278,292,315,191,177,228,291,204,310,266] }
assert my_solution.minProcessingTime(**test_input) == 526

test_input = { "processorTime": [177,6,326,318,294], "tasks": [136,215,260,259,35,248,340,377,144,248,83,150,63,48,269,197,317,135,36,344] }
assert my_solution.minProcessingTime(**test_input) == 542

test_input = { "processorTime": [266,372], "tasks": [260,325,159,316,296,366,335,146] }
assert my_solution.minProcessingTime(**test_input) == 668

test_input = { "processorTime": [63,339], "tasks": [79,316,98,354,220,267,333,11] }
assert my_solution.minProcessingTime(**test_input) == 559

test_input = { "processorTime": [149,60,172,5,212], "tasks": [230,374,276,281,55,96,52,83,56,399,69,333,145,6,50,101,216,327,120,209] }
assert my_solution.minProcessingTime(**test_input) == 404

test_input = { "processorTime": [220,375,285,267,150], "tasks": [53,317,367,258,337,280,232,322,153,169,121,211,171,345,76,370,265,107,45,320] }
assert my_solution.minProcessingTime(**test_input) == 542

test_input = { "processorTime": [373,367,267], "tasks": [214,221,78,330,340,309,330,338,396,337,285,207] }
assert my_solution.minProcessingTime(**test_input) == 697

test_input = { "processorTime": [92,20], "tasks": [11,354,399,11,20,9,217,372] }
assert my_solution.minProcessingTime(**test_input) == 419

test_input = { "processorTime": [51], "tasks": [349,186,191,183] }
assert my_solution.minProcessingTime(**test_input) == 400

test_input = { "processorTime": [362,220,10,219], "tasks": [160,369,385,145,122,124,147,231,162,37,293,160,68,232,232,130] }
assert my_solution.minProcessingTime(**test_input) == 486

test_input = { "processorTime": [210,348,3,57,174], "tasks": [328,296,222,161,190,381,283,137,353,227,284,134,170,13,275,113,148,198,33,260] }
assert my_solution.minProcessingTime(**test_input) == 482

test_input = { "processorTime": [153], "tasks": [342,166,234,175] }
assert my_solution.minProcessingTime(**test_input) == 495

test_input = { "processorTime": [23,204,114,380,3], "tasks": [40,105,311,221,247,34,399,190,23,289,16,129,68,12,32,364,364,111,361,49] }
assert my_solution.minProcessingTime(**test_input) == 412

test_input = { "processorTime": [167,110,221,19,211], "tasks": [140,351,307,4,262,228,161,200,108,206,280,266,240,258,396,194,333,328,121,179] }
assert my_solution.minProcessingTime(**test_input) == 425

test_input = { "processorTime": [179,127,280,242], "tasks": [244,243,92,188,134,84,22,258,100,77,237,83,41,396,218,87] }
assert my_solution.minProcessingTime(**test_input) == 523

test_input = { "processorTime": [45,249,396,163], "tasks": [131,365,52,366,229,340,242,371,20,181,103,97,141,106,46,119] }
assert my_solution.minProcessingTime(**test_input) == 493

test_input = { "processorTime": [205], "tasks": [117,63,174,87] }
assert my_solution.minProcessingTime(**test_input) == 379

test_input = { "processorTime": [128,101,302,53], "tasks": [265,96,358,287,148,117,331,47,173,347,62,145,73,47,206,29] }
assert my_solution.minProcessingTime(**test_input) == 411

test_input = { "processorTime": [228], "tasks": [321,378,268,351] }
assert my_solution.minProcessingTime(**test_input) == 606

test_input = { "processorTime": [136,22,229,187], "tasks": [246,326,188,341,375,207,334,1,189,301,62,39,44,239,346,376] }
assert my_solution.minProcessingTime(**test_input) == 470

test_input = { "processorTime": [47,238,274], "tasks": [251,312,87,111,142,62,112,325,305,164,85,338] }
assert my_solution.minProcessingTime(**test_input) == 489

test_input = { "processorTime": [386,121,249], "tasks": [5,376,53,187,287,369,400,178,293,121,164,336] }
assert my_solution.minProcessingTime(**test_input) == 550

test_input = { "processorTime": [82,152], "tasks": [82,46,149,255,225,93,227,131] }
assert my_solution.minProcessingTime(**test_input) == 337

test_input = { "processorTime": [394,6], "tasks": [231,236,288,35,247,204,141,41] }
assert my_solution.minProcessingTime(**test_input) == 598

test_input = { "processorTime": [389,54], "tasks": [353,358,211,133,225,358,19,310] }
assert my_solution.minProcessingTime(**test_input) == 614

test_input = { "processorTime": [106,291,291,301], "tasks": [192,120,93,5,293,147,299,81,334,137,259,48,296,117,379,182] }
assert my_solution.minProcessingTime(**test_input) == 584

test_input = { "processorTime": [320,139], "tasks": [210,255,304,181,216,255,375,360] }
assert my_solution.minProcessingTime(**test_input) == 575

test_input = { "processorTime": [306,207,295], "tasks": [335,188,355,209,201,113,122,206,46,355,350,38] }
assert my_solution.minProcessingTime(**test_input) == 562

test_input = { "processorTime": [175,111], "tasks": [225,110,163,100,353,77,12,124] }
assert my_solution.minProcessingTime(**test_input) == 464

test_input = { "processorTime": [233,201], "tasks": [1,389,291,333,42,399,399,300] }
assert my_solution.minProcessingTime(**test_input) == 600

test_input = { "processorTime": [302,5,102,195], "tasks": [311,144,7,277,253,96,136,251,81,195,171,140,73,2,84,42] }
assert my_solution.minProcessingTime(**test_input) == 375

test_input = { "processorTime": [151,185,3,137], "tasks": [294,230,221,216,299,24,79,194,375,387,77,388,366,51,117,126] }
assert my_solution.minProcessingTime(**test_input) == 436

test_input = { "processorTime": [39,141,145,199], "tasks": [99,257,161,121,56,80,235,168,171,228,290,180,118,307,66,151] }
assert my_solution.minProcessingTime(**test_input) == 369

test_input = { "processorTime": [40,67], "tasks": [259,217,337,295,126,335,369,123] }
assert my_solution.minProcessingTime(**test_input) == 409

test_input = { "processorTime": [310,56,207,396], "tasks": [260,255,30,243,66,11,285,31,358,219,218,90,176,346,134,74] }
assert my_solution.minProcessingTime(**test_input) == 486

test_input = { "processorTime": [174,48], "tasks": [106,323,4,247,70,281,348,12] }
assert my_solution.minProcessingTime(**test_input) == 396

test_input = { "processorTime": [16,52,13], "tasks": [281,261,55,165,317,150,68,26,52,227,176,399] }
assert my_solution.minProcessingTime(**test_input) == 412

test_input = { "processorTime": [8,315,115,123], "tasks": [134,371,160,138,289,330,48,349,376,88,46,235,298,321,343,365] }
assert my_solution.minProcessingTime(**test_input) == 458

test_input = { "processorTime": [221,24,372,6,50], "tasks": [274,79,78,37,57,39,102,272,242,283,95,155,105,363,174,1,333,400,375,376] }
assert my_solution.minProcessingTime(**test_input) == 429

test_input = { "processorTime": [289,98,7,303,219], "tasks": [363,140,173,92,52,348,350,316,281,327,40,259,39,235,263,244,42,354,11,232] }
assert my_solution.minProcessingTime(**test_input) == 478

test_input = { "processorTime": [348,268], "tasks": [104,397,333,188,373,325,57,202] }
assert my_solution.minProcessingTime(**test_input) == 665

test_input = { "processorTime": [18,377,305,188,311], "tasks": [207,365,369,66,263,47,257,317,221,292,386,308,357,105,99,314,133,106,311,90] }
assert my_solution.minProcessingTime(**test_input) == 597

test_input = { "processorTime": [44,254], "tasks": [277,361,398,276,84,105,350,134] }
assert my_solution.minProcessingTime(**test_input) == 530

test_input = { "processorTime": [270,257,58], "tasks": [212,151,50,78,91,110,399,360,108,192,142,115] }
assert my_solution.minProcessingTime(**test_input) == 457

test_input = { "processorTime": [108,301], "tasks": [150,143,119,160,340,139,72,349] }
assert my_solution.minProcessingTime(**test_input) == 457

test_input = { "processorTime": [231,207,162,49], "tasks": [318,289,351,103,19,77,65,116,94,234,139,246,80,184,286,397] }
assert my_solution.minProcessingTime(**test_input) == 448

test_input = { "processorTime": [252], "tasks": [384,281,207,33] }
assert my_solution.minProcessingTime(**test_input) == 636

test_input = { "processorTime": [199,8,129,204], "tasks": [308,133,366,272,373,343,357,159,378,149,185,248,190,1,142,199] }
assert my_solution.minProcessingTime(**test_input) == 472

test_input = { "processorTime": [135,65,19,225], "tasks": [183,135,138,142,282,141,349,236,57,333,258,353,152,396,152,191] }
assert my_solution.minProcessingTime(**test_input) == 415

test_input = { "processorTime": [199,371,283,70], "tasks": [244,7,226,230,331,232,332,288,151,360,26,87,49,188,269,375] }
assert my_solution.minProcessingTime(**test_input) == 513

test_input = { "processorTime": [184,378], "tasks": [105,239,221,343,276,359,86,84] }
assert my_solution.minProcessingTime(**test_input) == 599

test_input = { "processorTime": [297,229,142,8,47], "tasks": [373,256,210,92,304,134,20,246,116,139,376,139,10,210,192,43,282,278,322,167] }
assert my_solution.minProcessingTime(**test_input) == 389

test_input = { "processorTime": [224,358,58,352], "tasks": [177,274,306,295,142,353,44,111,325,328,394,168,300,15,252,389] }
assert my_solution.minProcessingTime(**test_input) == 626

test_input = { "processorTime": [318,321,264,259], "tasks": [316,284,127,227,269,332,317,364,220,130,330,155,45,205,369,42] }
assert my_solution.minProcessingTime(**test_input) == 628

test_input = { "processorTime": [295,214,130], "tasks": [316,395,280,122,27,224,40,210,99,366,55,183] }
assert my_solution.minProcessingTime(**test_input) == 525

test_input = { "processorTime": [81,38,313,121], "tasks": [158,304,127,214,34,298,95,188,56,391,317,99,304,101,266,302] }
assert my_solution.minProcessingTime(**test_input) == 429

test_input = { "processorTime": [8,400,28,348,193], "tasks": [72,391,149,264,370,183,365,102,201,348,341,176,338,186,97,156,47,125,61,202] }
assert my_solution.minProcessingTime(**test_input) == 504

test_input = { "processorTime": [0], "tasks": [8,369,353,14] }
assert my_solution.minProcessingTime(**test_input) == 369

test_input = { "processorTime": [55,364,28,246], "tasks": [396,357,37,400,239,327,5,387,70,389,323,213,322,111,179,19] }
assert my_solution.minProcessingTime(**test_input) == 485

test_input = { "processorTime": [288,219,356,146,282], "tasks": [390,46,24,391,222,241,281,33,400,312,290,11,147,282,204,214,22,178,77,156] }
assert my_solution.minProcessingTime(**test_input) == 546

test_input = { "processorTime": [60,309,40,219,294], "tasks": [267,94,238,338,279,48,164,371,302,110,247,392,83,107,389,46,92,273,131,136] }
assert my_solution.minProcessingTime(**test_input) == 466

test_input = { "processorTime": [357], "tasks": [211,344,270,324] }
assert my_solution.minProcessingTime(**test_input) == 701

test_input = { "processorTime": [220,355,190,393], "tasks": [158,27,113,335,382,172,285,373,104,177,247,321,197,22,347,136] }
assert my_solution.minProcessingTime(**test_input) == 572

test_input = { "processorTime": [67,105,290,26,343], "tasks": [50,118,302,74,198,56,292,46,337,27,394,69,109,287,274,283,346,132,77,352] }
assert my_solution.minProcessingTime(**test_input) == 420

test_input = { "processorTime": [77,143,142,23], "tasks": [336,190,105,87,102,254,295,243,400,254,96,303,350,191,331,70] }
assert my_solution.minProcessingTime(**test_input) == 423

test_input = { "processorTime": [319,58,155,360], "tasks": [311,257,35,330,235,159,293,204,298,240,233,250,309,242,262,324] }
assert my_solution.minProcessingTime(**test_input) == 593

test_input = { "processorTime": [28,225,347], "tasks": [176,57,60,81,161,66,13,294,145,239,295,210] }
assert my_solution.minProcessingTime(**test_input) == 413

test_input = { "processorTime": [291,337], "tasks": [210,378,169,400,182,290,386,360] }
assert my_solution.minProcessingTime(**test_input) == 691

test_input = { "processorTime": [141,310], "tasks": [396,56,241,289,21,254,196,165] }
assert my_solution.minProcessingTime(**test_input) == 537

test_input = { "processorTime": [204,390,104], "tasks": [355,4,287,161,230,242,218,12,321,28,341,326] }
assert my_solution.minProcessingTime(**test_input) == 551

test_input = { "processorTime": [299,258], "tasks": [20,44,341,172,118,185,369,249] }
assert my_solution.minProcessingTime(**test_input) == 627

test_input = { "processorTime": [107,141,178,211,62], "tasks": [215,318,196,251,71,144,10,208,113,17,13,263,367,42,85,267,212,54,36,54] }
assert my_solution.minProcessingTime(**test_input) == 429

test_input = { "processorTime": [101,383,326,62], "tasks": [304,256,281,240,180,387,318,368,331,267,14,91,93,147,156,394] }
assert my_solution.minProcessingTime(**test_input) == 582

test_input = { "processorTime": [221,62,187,104,266], "tasks": [284,378,9,288,173,327,329,202,3,383,105,213,175,201,196,305,162,161,127,347] }
assert my_solution.minProcessingTime(**test_input) == 445

test_input = { "processorTime": [328,162,249,357,35], "tasks": [77,275,231,298,273,257,88,339,261,147,229,392,156,63,90,97,219,353,66,91] }
assert my_solution.minProcessingTime(**test_input) == 480

test_input = { "processorTime": [7], "tasks": [132,278,270,176] }
assert my_solution.minProcessingTime(**test_input) == 285

test_input = { "processorTime": [326], "tasks": [269,211,137,244] }
assert my_solution.minProcessingTime(**test_input) == 595

test_input = { "processorTime": [310,44], "tasks": [109,250,222,275,268,332,146,328] }
assert my_solution.minProcessingTime(**test_input) == 560

test_input = { "processorTime": [184,254,121,90,389], "tasks": [124,365,400,167,109,207,369,37,174,287,41,114,388,158,125,283,119,254,210,399] }
assert my_solution.minProcessingTime(**test_input) == 503

test_input = { "processorTime": [94,171,66], "tasks": [261,134,26,281,29,253,84,333,90,157,382,263] }
assert my_solution.minProcessingTime(**test_input) == 448

test_input = { "processorTime": [5,99,318,252,151], "tasks": [264,235,250,347,376,57,73,7,178,45,220,148,159,379,89,73,159,172,228,39] }
assert my_solution.minProcessingTime(**test_input) == 400

test_input = { "processorTime": [303,52,2,118,305], "tasks": [398,173,5,301,169,389,126,212,384,359,222,340,267,173,264,238,141,44,144,148] }
assert my_solution.minProcessingTime(**test_input) == 476

test_input = { "processorTime": [177], "tasks": [164,277,289,197] }
assert my_solution.minProcessingTime(**test_input) == 466

test_input = { "processorTime": [297,259,318,30,213], "tasks": [162,97,265,153,216,233,286,346,389,208,55,345,308,197,266,292,369,320,1,235] }
assert my_solution.minProcessingTime(**test_input) == 533

test_input = { "processorTime": [290], "tasks": [333,282,72,362] }
assert my_solution.minProcessingTime(**test_input) == 652

test_input = { "processorTime": [372,189,344], "tasks": [191,26,247,99,395,270,192,340,60,78,260,395] }
assert my_solution.minProcessingTime(**test_input) == 604