注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
1. Min read days
There are n chapters to be studied where the ith chapter has pages[i] pages. In one day, the student decides to read up to p of the remaining pages, each from some k consecutive chapters. Thus, the number of pages remaining to be read is reduced by p from each of these chapters. If a chapter has less than p pages remaining, the student reads the remaining pages, and the remaining page count is set to 0 for subsequent days. Find the minimum number of days the student needs to read all the chapters completely, i.e., the remaining page count of all chapters is 0.
Note:2,3,2,2,1,2]
there are 4 elements value k=2, and this is maximal, return 4
Constraints:- 1 ≤ n ≤ 2 × 10⁵
- 1 ≤ arr[i] ≤ 2 × 10⁵
- 1 ≤ k ≤ 2 × 10⁵
Example 1:- arr = [6, 4, 4, 6, 4, 4]
- k = 6
- Choose subarray [1:5] and add x = 2
- output: 5
Example 2:- arr = [2, 5, 2, 5, 2]
- k = 2
- Choose subarray [1:3] and add x = -3
- output: 4
有用请加米谢谢 |