P15977 [PA 2026] Daylight Saving Time / Zmiana czasu

Description

This year, the daylight saving time change happens during PA. Does that mean you have one less hour in the weekend round? Unfortunately, yes. We are sorry about that. This year, Bajtazar has decided that he will qualify for the finals. Instead of giving up halfway like in previous years, he wants to use his time as wisely as possible and plan exactly how much time he will spend on each problem. Recall the schedule of PA this year: | Round | Problem release time | Submission deadline | |------|-----------------------|---------------------| | 1 | March 23 $12\text{:}00$ | March 24 $23\text{:}59\text{:}59$ | | 2 | March 24 $12\text{:}00$ | March 25 $23\text{:}59\text{:}59$ | | 3 | March 25 $12\text{:}00$ | March 26 $23\text{:}59\text{:}59$ | | 4 | March 26 $12\text{:}00$ | March 27 $23\text{:}59\text{:}59$ | | 5 | March 27 $12\text{:}00$ | March 29 $23\text{:}59\text{:}59$ | The daylight saving time change will occur on March 29 at $2\text{:}00$, when the clock will be moved forward to $3\text{:}00$. Write a program to help Bajtazar compute the following: given the time when he starts solving, how much time he still has to solve during a given round.

Input Format

The single line of input contains four integers $x, d, h, m$ ($1 \le x \le 5$, $23 \le d \le 29$, $0 \le h \le 23$, $0 \le m \le 59$), representing the round number of the problem, and the date, hour, and minute when Bajtazar starts solving. It is guaranteed that the given date and time lie within the contest period of round $x$, and that it is a valid Polish time, i.e., it will not fall within the skipped hour during the daylight saving time change. More precisely, the input will never contain the case $d = 29$ and $h = 2$.

Output Format

Output one integer: the number of minutes Bajtazar has for solving.

Explanation/Hint

**Explanation of the samples**: In the first sample, Bajtazar starts solving at the exact moment when the first round problems are released, so he has the full time of one round, i.e., $36$ hours, which is $2160$ minutes. In the second sample, Bajtazar starts solving on Saturday at $13\text{:}14$ (unfortunately, he spent the whole Friday debugging problem 4A, and then he had to get some proper sleep), so from that moment until midnight on Saturday he has $646$ minutes, plus $23$ hours on Sunday (because of the daylight saving time change), for a total of $646 + 23 \cdot 60 = 2026$ minutes. Translated by ChatGPT 5