← 返回 optiver 的题目列表Multi-Core Overheat Prevention Controller
类型:online_judge
Implement an OverheatPreventionController that simulates thermal behavior and overheating protection for a multi-core processor. The controller has no temperature sensors; it must calculate each core's temperature from configured workloads, passive cooling allocation, and active cooling state.
Implement:
class OverheatPreventionController:
def __init__(
self,
passive_cooling_capacity: float,
active_cooling_capacity_per_core: float,
core_ids: list[str],
): ...
def SetCoreLoad(self, timestamp: float, core_id: str, load_watts: float) -> None: ...
def Tick(self, timestamp: float) -> list[str]: ...
All cores initially run at 20.0°C, with load 0W, active cooling disabled, and status idle.
SetCoreLoad records a lazy load update that takes effect only at the next Tick. Multiple updates for the same core between ticks collapse to the last update. If the core was shut down when SetCoreLoad was called, the update is a restart request: it succeeds at the next tick only if the observed temperature is strictly below 50°C; otherwise it is discarded.
Tick(timestamp) must:
Advance all temperatures from the prior tick to timestamp.
Shut down every running core with temperature >= 80°C, clearing its load.
Apply pending load updates and valid restart attempts.
Select the minimum necessary set of running cores for active cooling during the next interval.
Return changed statuses as sorted "core_id=status" strings.
A status is idle (running without active cooling), cooling (running with active cooling), or shutdown.
Temperature changes linearly at:
0.02 °C/s × (load - allocated_passive_cooling - allocated_active_cooling)
and never drops below 20.0°C.
Each core's passive demand is load + 2W. If total demand fits in the effective passive capacity, every core receives its full demand; otherwise capacity is allocated proportionally to demand.
A core with active cooling receives exactly active_cooling_capacity_per_core additional watts of cooling. When k cores use active cooling, effective passive capacity is:
passive_cooling_capacity * (1 - vibration_penalty(k) / 100)
where:
vibration_penalty(0) = 0
vibration_penalty(k) = sum(10 / Fib_i), i = 1..k
and Fib_i is 1, 2, 3, 5, 8, 13, ....
At the end of a tick, active cooling must be enabled for the minimum number of cores satisfying:
Every running core above 60°C is enabled.
Any running core that would rise faster than 0.5°C/s without active cooling under the current candidate passive-capacity penalty is enabled.
Since adding active cooling worsens passive cooling through vibration, repeatedly re-evaluate until no additional core must be enabled.
Constraints: fewer than 2^10 cores and fewer than 2^10 operations; timestamps are globally increasing.
Example
Input
100 20 2
coreA
coreB
1
TICK 10
Output