Nila inherited the timber yard at the saffron fields of Marigold Row along with its curious bookkeeping system for contracts. Time to make sense of it. Task: n tasks of types 0..T must run with at least k idle/other tasks between two same-type tasks. Print the minimum total time including any needed idles. Input format: First line: n and k. Second line: n task types. Output format: Print the minimum completion time. Constraints: 1 <= n <= 4000; 0 <= k <= 100; 0 <= type < 1000.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= n <= 4000; 0 <= k <= 100; 0 <= type < 1000.
