leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2439.cpp (270B)


      1 class Solution {
      2   public:
      3     int minimizeArrayValue(vector<int> &nums) {
      4         long sum = 0, res = 0;
      5         for (int i = 0; i < nums.size(); ++i) {
      6             sum += nums[i];
      7             res = max(res, (sum + i) / (i + 1));
      8         }
      9         return res;
     10     }
     11 };