Advertisement
noshin98

uva 10684

Mar 7th, 2017
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include <cstdio>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int n, i, x[100000];
  6.  
  7.     while (scanf("%d", &n), n) {
  8.         for (i = 0; i < n; i++) {
  9.             scanf("%d", &x[i]);
  10.         }
  11.  
  12.         int max = 0, temp = 0;
  13.         for (i = 0; i < n; i++) {
  14.             temp += x[i];
  15.             if (temp > max)
  16.                 max = temp;
  17.             if (temp < 0)
  18.                 temp = 0;
  19.         }
  20.  
  21.         if (max > 0)
  22.             printf("The maximum winning streak is %d.\n", max);
  23.         else
  24.             printf("Losing streak.\n");
  25.     }
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement