Ankit_132

Ball Distribution

Jul 12th, 2023
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define ll     long long
  7. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  8.  
  9. int main()
  10. {
  11.     _test
  12.     {
  13.         ll int n, m;
  14.         cin>>n>>m;
  15.  
  16.         vector<ll int> a(m);
  17.         for(auto &e: a)     cin>>e;
  18.  
  19.         ll int tot = accumulate(a.begin(), a.end(), 0ll);
  20.  
  21.         ll int mmin = (m-1)*1ll*n;
  22.  
  23.         cout<<max(0ll, tot-mmin)<<"\n";
  24.     }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment