Anurag is posed with a very serious problem. He will be in London during the summers…
- User
Anurag is posed with a very serious problem. He will be in London during the summers from days [ a,b ] for an internship. But he also wants to attend the ACM-ICPC World Finals with his team to be held in Thailand during [ c,d ] days. The opening ceremony for the World Finals will be held on c day. He found out that it would take him S time (in days) to travel from London to Thailand. He wonders what is the maximum time L in the interval [ a,b ], at which he will have to leave so as to reach Thailand on or before the opening ceremony. If it is not possible for him to reach on or before the opening ceremony, print STAY IN LONDON. Input
The first line contains a single integer T, denoting the number of test cases. Next T lines contain five integers each a b c d and S. Output
For each test case, you need to output the answer in a new line.
Constraints
1 ≤ T ≤ 100000 1 ≤ a ≤ b ≤ 100000 b ≤ c ≤ d ≤ 100000 1 ≤ S ≤ 100000
SAMPLE INPUT 2 1 14 15 20 2 13 14 15 20 3
SAMPLE OUTPUT 13 STAY IN LONDON
Assistant
import sys def main(): input = sys.stdin.read data = input().split() idx = 0 T = int(data[idx]) idx += 1 for _ in range(T): a = int(data[idx]) b = int(data[idx+1]) c = int(data[idx+2]) d = int(data[idx+3]) S = int(data[idx+4]) idx +=5 latest_possible = c - S max_L = min(b, latest_possible) if max_L >= a: print(max_L) else: print("STAY IN LONDON") if __name__ == "__main__": main()
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.