⌘K
Flycodx

Ration Shop Fair Allocation Validator

Ration Shop Fair Allocation Validator

MediumArrays100% accepted

A Mumbai ration shop ensures fair grain distribution. No family receives more than L kg, and any consecutive group's total cannot exceed S kg. Given allocation array, find longest consecutive family group respecting both fairness constraints. Rule: return the longest contiguous group where EVERY allocation <= L and the group total <= S. Your solve(...) function receives the inputs as ready-made arguments — no input reading or parsing needed; just return the answer.

Approach

Given array of allocations, per-family limit L, and group limit S, find longest consecutive subarray respecting both constraints.

Input

allocations=[5,10,3,2,8] L=10 S=20

Output

4
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