Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Eaten Apples

med
30 min
Try to solve the Maximum Number of Eaten Apples problem.

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 ≤2imes104\leq 2 imes 10^4

  • 0≤0 \leq apples[i], days[i] ≤2imes104\leq 2 imes 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

med
30 min
Try to solve the Maximum Number of Eaten Apples problem.

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 ≤2imes104\leq 2 imes 10^4

  • 0≤0 \leq apples[i], days[i] ≤2imes104\leq 2 imes 10^4

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