[Codeforces] 673A: Bear and Game – | Let’s learn some algorithm by ourselves and solve the problem “673A: Bear and Game ” on Codeforces Come on. My coding ability is limited, so I hope to receive better feedback as well as other solutions from you.

Title “673A: Bear and Game”

You go to the homework link Codeforces 673A below to see the full information.



The first line of the input contains one integer n (1 ≤ n≤ 90) – the number of interesting minutes.

The second line contains n integers tfirst,t2, …,tn (1 ≤tfirst<t2<≤ 90), given in the increasing order.


Print the number of minutes Limak will watch the game

Example 1:

Example 2:

My idea:

  • I loop the elements in the interest time array.
  • Subtract the previous value from the current element value, if it is greater than 15, then the character has watched over 15 minutes of frustration in the ball game.
    => Then will calculate the number of minutes considered in the match and break loop.
  • If the value is not greater than 15, skip to the next element values.
    + If Index value is 0 or final, then closing the match time is not boring.

Link code github solution:

Submit the solution on Codeforces problem 637A:


Previous articleVPC Reachability Analyzer – An AWS network connection debugging service

You are following the website “” which stores general knowledge and personal sharing about Network & Service System Administration, rebuilt under the foundation of own experience. me, Quach Chi Cuong. Hope you enjoy this place!

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *