Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Eaten Apples

Maximum Number of Eaten Apples gives daily apple counts and shelf lives. Return the most apples you can eat, at most one per day, including after production ends, before they spoil.

Statement

There is a special apple tree that produces apples for n consecutive days. On day i (starting from day 00), the tree produces apples[i] apples that will spoil after days[i] days. Specifically, any apple grown on day i rots on day i+i + days[i] and can no longer be consumed on or after that day. On some days, the tree might not yield any apples, represented by apples[i] =0= 0 and days[i] =0= 0.

You can eat at most 11 apple per day, and you may continue eating apples after the initial n days have elapsed.

Return the maximum number of apples you can eat.

Constraints:

  • n $= $ apples.length $= $ days.length

  • 1≤1 \leq n ≤2×104\leq 2 \times 10^4

  • 0≤0 \leq apples[i], days[i] ≤2×104\leq 2 \times 10^4

  • days[i] =0= 0 if and only if apples[i] =0= 0

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Eaten Apples

Maximum Number of Eaten Apples gives daily apple counts and shelf lives. Return the most apples you can eat, at most one per day, including after production ends, before they spoil.

Statement

There is a special apple tree that produces apples for n consecutive days. On day i (starting from day 00), the tree produces apples[i] apples that will spoil after days[i] days. Specifically, any apple grown on day i rots on day i+i + days[i] and can no longer be consumed on or after that day. On some days, the tree might not yield any apples, represented by apples[i] =0= 0 and days[i] =0= 0.

You can eat at most 11 apple per day, and you may continue eating apples after the initial n days have elapsed.

Return the maximum number of apples you can eat.

Constraints:

  • n $= $ apples.length $= $ days.length

  • 1≤1 \leq n ≤2×104\leq 2 \times 10^4

  • 0≤0 \leq apples[i], days[i] ≤2×104\leq 2 \times 10^4

  • days[i] =0= 0 if and only if apples[i] =0= 0