33OJ
登录 注册

#P18090. [UKIEPC 2026] Mid Clocking

[UKIEPC 2026] Mid Clocking

Problem Description

A row of slots can hold processors. Each processor handles only one task and enters a busy-wait state after completing it, waiting for the next instruction.

When a processor has no immediately adjacent processor on either side, it has sufficient cooling and can reach 100%100\% of its maximum speed. If it has 11 immediately adjacent processor, it can reach only 60%60\% of its maximum speed. If it has 22 immediately adjacent processors, it can reach only 30%30\% of its maximum speed.

image.png

Figure M.1: Illustration of Sample 2.

All tasks start at t=0t=0. Given the number of seconds each task requires when its processor runs at full speed, assign tasks to processors so that the last task finishes as early as possible.

Input Format

The input first gives the number of tasks nn and the number of processor slots ss (1≤n≤s≤1061 \le n \le s \le 10^6).

Then nn integers follow, representing the times tit_i required by the tasks when their processors run at 100%100\% of their maximum speed (1≤ti≤1091 \le t_i \le 10^9), in seconds.

Output Format

Output the minimum time required to complete all tasks.

The absolute or relative error of your output must not exceed 10−610^{-6}.

4 5
1 1000 1 1
1000
7 10
5 2 3 5 4 6 7
8.33333333

Hint

Translated by QwenWork