- Competitive Programming Chapter 1
- Competitive Programmer's Handbook page 3 to 21
- see part 148A - Insomnia cure in this editorial
- see part 443A - Anton and Letters in this editorial
- see part B 158B - Taxi in this editorial
- see part 166A - Rank List in this editorial
- see part Rock, Scissors, Paper this editorial. also see code
- see part 688B: Lovely Palindromes in this editorial
- see part Guess the Permutation in this editorial
- see part 912B - New Year's Eve in this editorial
- see part 197A - Plate Game in this editorial
- see part Traffic Lights in this section
You should search over all 5 hours (18000 seconds) to find a second which all of the traffic lights show green simultaneously. For every input x, we know that its light cycle is 2x seconds and its green period is between start of the cycle and x-5 (after x- 5 seconds, the light turns orange) Notice that you should start searching from one second after the first light turns red, due to assumption of the question. For exmaple for the first test case, start searching from second 20 (19+1) which first light has turned red , you wil find that in second 40 both of the lights are green.
see code