Advertisement
Promi_38

cf 1537A

Oct 3rd, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include<bits\stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int t;
  8.     cin >> t;
  9.    
  10.     while(t--)
  11.     {
  12.         int n;
  13.         cin >> n;
  14.        
  15.         int a[n], i, sum = 0;
  16.         for(i = 0; i < n; i++)
  17.         {
  18.             cin >> a[i];
  19.             sum += a[i];
  20.         }
  21.         if(sum > 0)
  22.         {
  23.             if(sum >= n) printf("%d\n", sum - n);
  24.             else printf("1\n");
  25.         }
  26.         else printf("1\n");
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement