Editorial for COCI '19 Contest 3 #1 Preokret


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

This task is made for beginners and consists of three parts, each slightly more difficult than the last.

In the first part, you were asked to determine what was the final score of the game. It was enough to simply count how many times did the numbers 1 and 2 occur in the input. This can be done simply by looping through the input data and storing that information in two variables.

In the second part, you were asked to determine the number of ties. Since you already know how many goals each team scored in every moment (from part 1), you can simply introduce another variable which should be increased whenever the number of scored goals was the same for both teams. You also needed to make sure to include the starting score (0:0).

In the third and final part, you were asked to determine what was the largest turnover. Note that each turnover consists of three parts. First, one team is losing and starts to score goals, then the score comes to a tie and finally that team starts winning. Suppose we store the difference in goals between the two teams. In that case, we are simply looking for the largest interval in which the difference at the start of the interval was negative and it became positive at the end (or vice versa).


Comments

There are no comments at the moment.