Advertisement
pierdziadek

#7 - Informatyka - 16.03.2020

Mar 16th, 2020
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <cstdio>
  2.  
  3. int main()
  4. {
  5.  
  6.     int n, x, a, b, m;
  7.     scanf("%i", &m);
  8.     while(m--){
  9.        scanf("%i", &n);
  10.         a = 1;
  11.         b = 0;
  12.         while(n--)
  13.         {
  14.             scanf("%i", &x);
  15.             if(!b)
  16.             {
  17.                 if(x > a)
  18.                     b = a;
  19.                 a += x;
  20.             }
  21.         }
  22.         printf("%i\n", b?b:a);
  23.     }
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement