Connection Status:
Competition Arena > CompetitionStatistics
SRM 259 · 2005-08-22 · by Andrew_Lazarev · Brute Force
Class Name: CompetitionStatistics
Return Type: int
Method Name: consecutiveGrowth
Arg Types: (vector<int>)
Problem Statement

Problem Statement

The longest consecutive rating increase streak is a very important statistic in any competition. You are to calculate this statistic for a certain player.

You will be given a int[] ratingChanges containing the rating changes of the player in chronological order. Your method should return the maximum number of consecutive competitions with positive rating changes. Note that 0 is not a positive number.

Constraints

  • ratingChanges will contain between 1 and 50 elements, inclusive.
  • Each element of ratingChanges will be between -1000 and 1000, inclusive.
Examples
0)
{30, 5, -5, 3, 3, 1}
Returns: 3

The player raises rating two times, afterwards reduces it once and finally raises it three times in a row.

1)
{-1, -5, -9}
Returns: 0

No rating changes are positive.

2)
{12, 0, 15, 73}
Returns: 2
3)
{12, 1, 15, 73}
Returns: 4
4)
{-6, 13, 15, -11, 12, 12, 33, 12, -1}
Returns: 4

Submissions are judged against all 79 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class CompetitionStatistics with a public method int consecutiveGrowth(vector<int> ratingChanges) · 79 test cases · 2 s / 256 MB per case

Submitting as anonymous