QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 1024 MB 満点: 10

#17383. Time change [C]

統計

It happened; this year the daylight saving time change falls during the Potyczki. Does this mean you have one hour less for the weekend round? Unfortunately yes, for which we sincerely apologize.

Bajtazar has decided to make it to the finals this year. Instead of giving up halfway through the contest (as he has done in previous years), he decided to make the best use of his time and carefully plan when he will work on each task.

Let us recall the schedule for this year's Potyczki:

ROUND TASK PUBLICATION SUBMISSION DEADLINE
1 March 23, 12:00 March 24, 23:59:59
2 March 24, 12:00 March 25, 23:59:59
3 March 25, 12:00 March 26, 23:59:59
4 March 26, 12:00 March 27, 23:59:59
5 March 27, 12:00 March 29, 23:59:59

The daylight saving time change will occur on March 29 at 2:00 AM, when we set the clocks forward to 3:00 AM. Write a program that will help Bajtazar calculate how much time he will have to complete a task from a given round, if we know the time at which he starts working on the task.

Input

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 respectively: the number of the round the task is from, and the day, hour, and minute at which Bajtazar started working on that task.

We guarantee that the given date and time are within the duration of round $x$, and describe a valid Polish time, meaning it is not during the hour skipped by the daylight saving time change. Specifically, the input will not contain the pair $(d, h)$ where $d = 29$ and $h = 2$.

Output

Print a single integer — the number of minutes Bajtazar has to complete the task.

Examples

Input 1

1 23 12 0

Output 1

2160

Input 2

5 28 13 14

Output 2

2026

Note

In the first example, Bajtazar started working on the ZMI task from the first round at the moment it was published; he has the entire duration of this round, which is 36 hours, or 2160 minutes.

In the second example, Bajtazar started working on the task from the weekend round on Saturday at 13:14 (unfortunately, he spent all of Friday debugging 4A and had to get some proper sleep), so he has 646 minutes until midnight from Saturday to Sunday and 23 hours on Sunday (due to the daylight saving time change), for a total of $646 + 23 \cdot 60 = 2026$ minutes.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.