⌘K
Flycodx

Power Grid Load Distribution

Power Grid Load Distribution

HardArrays0% accepted

Delhi's power distribution authority must balance load across N substations over 24 hours. Each hour's load must be distributed such that no subarray exceeds maximum capacity. Find the minimum peak load after optimal distribution.

Approach

Given an array of N hourly loads, find a partition into K segments where the maximum segment sum is minimized (load balancing).

Input

loads=[7,2,5,10,8], K=2

Output

18
solution.py
Loading editor...
Test 1
Test 2
Test 3

Press Run to test your custom input, or Submit to judge against all test cases.

Sign in to continue

Create a free account to run code, submit solutions and track progress.

  • Free forever — no credit card
  • 10+ languages with live execution
  • Points, streaks & leaderboards
Auto Save OnLn 1, Col 1Spaces: 4UTF-8LFPython 3