Rain Prediction

advertisement
Rain Prediction
Filename: rain
The Problem
Unfortunately, rain cut the IOA/Universal field trip short. For next year's BHCSI, Jill would like
to plan the field trip for the day during the camp where rain is least likely. Since rain prediction
is so difficult, Jill is only asking you to write a program that calculates the longest streak of
consecutive days with rain and the longest streak of consecutive days without rain from past
records. For this problem you'll look at several sets of rain data and have to determine the length
of these two streaks.
The Input
The first line of the input file will consist of a single integer n representing how many sets of
data you will solve. For each set of data, the first line of input will contain one integer k (0 < k ≤
1000), representing the number of days of data for the set of data. The following k lines will each
contain one floating point number representing the amount of rainfall for that day. Each of these
numbers will be non-negative floating point numbers less than 10 with exactly 2 digits past the
decimal representing the amount of rainfall in inches for that day.
The Output
For every data set, the first line will be of the following format:
Data Set #m:
where m is the number of the data set starting with 1.
The second and third lines will be of the following formats respectively:
Longest Streak of Rain: X Day(s)
Longest Streak without Rain: Y Day(s)
where X and Y are the longest streak of days in a row with and without rain, respectively, for the
data set.
Put a blank line of output between the output for each data set.
Sample Input
2
5
0.00
0.00
0.00
0.23
0.44
10
1.01
1.11
0.00
0.00
1.01
0.00
0.34
0.54
0.12
0.01
Sample Output
Data Set #1:
Longest Streak of Rain: 2 Day(s)
Longest Streak without Rain: 3 Day(s)
Data Set #2:
Longest Streak of Rain: 4 Day(s)
Longest Streak without Rain: 2 Day(s)
Download