Programming contests

DEIK Regionális Programozó Csapatverseny, középiskolai kategória, 2015. november 29.

November 29, 2015 10:40 AM – November 29, 2015 3:40 PM

The Jackpot

As Manuel wants to get rich fast and without too much work, he decided to make a career in gambling. Initially, he plans to study the gains and losses of players, so that he can identify patterns of consecutive wins and elaborate a win-win strategy. But Manuel, as smart as he thinks he is, does not know how to program computers. So he hired you to write programs that will assist him in elaborating his strategy.

Your first task is to write a program that identifies the maximum possible gain out of a sequence of bets. A bet is an amount of money and is either winning (this is recorded as a positive value) or losing (recorded as a negative value).

Input Specification

The input contains several test cases. Each test case consists of a positive integer N ≤ 10000 that gives the length of the sequence, followed by N integers. Each integer represents either a winning bet (as a positive value) or a losing bet (as a negative value). Each bet is an integer greater than 0 and less than 1000.

The input is terminated with N = 0.

Output Specification

For each test case given in the input, the output will echo a line with the corresponding solution. See the sample output for the exact format. If the sequence shows no possibility to win money, then the output is the message “Losing streak.

Sample Input

  1. 5
  2. 12 -4
  3. -10 4
  4. 9
  5. 3
  6. -2 -1 -2
  7. 0
download as text file

Output for Sample Input

  1. The maximum winning streak is 13.
  2. Losing streak.
download as text file
University of Debrecen; Faculty of Informatics; v. 05/24/2018