print1405. Crap Streak

printCrap Streak

Ограничения: время – 2s/4s, память – 64MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

Craps is a dice game in which players place wagers on the outcome of a roll of a pair of dice. One kind of wager in craps is called a field bet, whose payout-the amount won or lost-is a multiple of the amount wagered. The following table shows the field bet payout on a $1 wager, for each roll outcome:
outcome payout ($)
2 2
3 1
4 1
5 –1
6 –1
7 –1
8 –1
9 1
10 1
11 1
12 3
In this problem, we consider a string of rolls of a pair of dice (with $1 wagers on each roll), and compute total payouts over various substrings. In a string of rolls, there might be some substrings that are winning streaks and some that are losing streaks. We seek to find the substring(s) that produce the highest total payout… the best winning streak(s).
Input Format
Any input line containing two numbers between 1 and 6 separated by white space constitutes a roll of a pair of dice, whose outcome is the total of the two numbers. One or more rolls followed by an empty input line constitutes a string of rolls. We consider the rolls within a string of rolls to be indexed starting at 1. The input consists of one or more strings of rolls.
Output Format
For each string of rolls in the input, compute the highest total payout over all substrings (of at least one roll), and give the starting and ending index of each such substring. Format the output as shown in the sample on the next page.

Sample Input

3 1
4 2
4 6

4 3
2 5
6 1

1 1
1 2
1 3
1 4
1 5
1 6
2 6
3 6
4 6
5 6
6 6

Sample Output

best winning streak is $1 from rolls 1-1 1-3 3-3
best winning streak is $-1 from rolls 1-1 2-2 3-3
best winning streak is $6 from rolls 1-11 8-11
Source: California State Polytechnic University Programming Contest, Spring 2010
loading