nikunjsoni

1953

Jul 31st, 2021
1,073
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  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. };
Advertisement
Add Comment
Please, Sign In to add comment