⌘K
Flycodx

Ration Shop Consecutive Allocation Feasibility

Ration Shop Consecutive Allocation Feasibility

HardArrays100% accepted

A Mumbai ration shop has items distributed in N consecutive bins with varying quantities. Families request allocations from consecutive bins. Determine if all family requests can be satisfied without conflicts. Rule: process requests in order; request [s,e,amount] takes grain greedily from bins s..e (left to right) out of what REMAINS. Return 'true' if every request is fully satisfied, else 'false'. Your solve(...) function receives the inputs as ready-made arguments — no input reading or parsing needed; just return the answer.

Approach

Given an array of bin quantities and a list of family requests [start, end, amount_needed], determine if each family can be allocated their required quantity from their requested bin range.

Input

bins=[10,20,15,30] requests=[[0,1,25],[1,2,35]]

Output

false
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