Following tremendous advances in space flight control software and equally impressive innovations in reality TV crowdfunding, humans have successfully settled a number of planets, moons, asteroids, and various other kinds of funny-shaped rocks across our solar system.
To celebrate, the Galactic President has elected to create a new holiday called "Solar Night". At the crux of the event, she decrees, every settlement will simultaneously launch colourful fireworks into the darkness of night.
Night, like most things, is a difficult problem in space. Every spacebound object has its own day length and period of rotation. Thankfully all of the settlements did, at least, start their clocks at the same moment. Settlements may have started in daylight or darkness and so it is possible that the first recorded sunrise can be either before or after the first hour of sunset.
By convention, the President’s term lasts for exactly $1825$ days as measured by the planet with the longest period of rotation. The celebration needs to happen within that time or it will not serve its intended purpose.
Determine how many hours must pass for us to find a suitable time to celebrate Solar Night.
- One line containing the integer $N$ ($1 \le N \le 20$), the number of settlements.
- $N$ lines, each containing three integers:
- $H$ ($2 \le H \le 100$), the number of hours in this settlement’s solar day.
- $R$ and $T$ ($0 \le R, T \le H - 1, R \neq T$), the hours of sunrise and sunset respectively.
At sunrise and sunset, a settlement is in darkness. At times strictly in between sunrise and sunset, a settlment is in daylight.
Output the number of hours that must pass from when the settlement clocks began until each settlement is in darkness. If no suitable time occurs in the first $1825$ days, output impossible.
## Sample Input 1
24 7 19
24 18 6
## Sample Output 1
## Sample Input 2
10 8 2
15 5 10
20 15 10
## Sample Output 2
## Sample Input 3
6 4 2
12 7 5
## Sample Output 3
## Sample Input 4
10 5 6
10 6 5
## Sample Output 4
ارسال پاسخ برای این سؤال
برای ارسال پاسخ باید ابتدا وارد سایت شوید.
کپی سؤال «Settlements»
ویژه اساتید و دستیاران آموزشی
با استفاده از این امکان، میتوانید از سؤالات موجود در بانک سؤالات کپی بگیرید و آنها را
به تمرینهای درس خود و یا مسابقات خود اضافه کنید.
مقصد کپی شدن این سؤال را انتخاب کنید. نکته: پیش از اقدام به کپی، باید در درس خود یک تمرین ایجاد کنید.