You are given a 0-indexed array
nums
comprising ofn
non-negative integers.
In one operation, you must:
- Choose an integer
i
such that1 <= i < n
andnums[i] > 0
.- Decrease
nums[i]
by 1.- Increase
nums[i - 1]
by 1.Return the minimum possible value of the maximum integer of
nums
after performing any number of operations.
Constraints:
n == nums.length
2 <= n <= 105
0 <= nums[i] <= 109
給你一個從索引值 0 開始的陣列
nums
,其包含n
個非負整數。
每次操作,你必須:
- 選一個整數
i
其中1 <= i < n
且nums[i] > 0
。- 將
num[i]
減一- 將
nums[i - 1]
加一回傳經過任意次數的操作後,陣列
nums
中最大數值的最小可能值為何。
限制:
n == nums.length
2 <= n <= 105
0 <= nums[i] <= 109
1
5
,因此範例測資一答案是 5
LeetCode
C++