nikunjsoni

1953

Jul 31st, 2021
908
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Solution {
  2. typedef long long ll;
  3. public:
  4.     long long numberOfWeeks(vector<int>& m) {
  5.         ll maxElement = *max_element(m.begin(), m.end());
  6.         ll sum = accumulate(m.begin(), m.end(), 0LL);
  7.         return min(sum, 2*(sum-maxElement)+1);
  8.     }
  9. };
RAW Paste Data