[Codeforces] 673A: Bear and Game – Cuongquach.com | 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<...tn≤ 90), given in the increasing order.
Print the number of minutes Limak will watch the game
#input 3 7 20 88 #output 35
7 20 88
#input 9 16 20 30 40 50 60 70 80 90 #output 15
16 20 30 40 50 60 70 80 90
- 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: https://github.com/cuongquach/cq-algo-challenges/blob/main/codeforces/673A/python/main.py
Submit the solution on Codeforces problem 637A: