Hdustm9 series of stories-weight loss II (discretization ideas)
Problem Description
Although I have developed a diet, I am obviously unable to restrain myself from the instinct of eating goods, and I have not followed the recipe!
The result is obvious...
But there is nothing to beat the high IQ of the beautiful girl, she decided to find another countermeasure-eat does not matter, we eat in and then sports consumption is not good?
"I am a genius ~ (Too many rows )/~"
However, you should know how busy it is to go home in the new year-to help you clean up the house, watch movies, read novels, have a dinner with high school students, have a dinner with junior high school students, eat, sleep, eat, and sleep, eating, sleeping ...... So it takes time to exercise.
However, Zookeeper is too busy, so I don't have time to calculate the amount of time a day can be used for exercise. Now she will tell you the daily schedule. Could you help me to calculate it ~
Pies: 24 hours a day. Input data every 60 Minutes includes multiple groups of test cases.
Each group of test data is first an integer n, indicating that there are n tasks to be done on the day.
The next n rows show the start time and end time of the I-th event. The time format is HH: MM.
[Technical Specification]
1. 1 <= n <= 500000
2. 00 <= HH <= 23
3. 00 <= MM <= 59
Output please Output an integer, that is, the time (in minutes) that the worker can use for exercise on the day Sample Input
115:36 18:40401:35 10:3604:54 22:3610:18 18:4011:47 17:53
Sample Output
1256179 question analysis: the time of a day is considered as 1440 minutes. If one minute I is occupied, vis [I] = 1. For each time period, it is converted to minutes to determine whether each minute is occupied, you can record it. The time can pass, and the maximum value is O (1440 * n). Well, there should be other methods to optimize it. AC code:
/*** @ Xiaoran * simulate a water question */# include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Define LL long using namespace std; const int sum = 1440; int vis [1444]; // record the time used to prevent repeated int addtime (int h1, int m1, int h2, int m2) {// calculate the time if (m2> = m1) return m2-m1 + (h2-h1) * 60; else return m2 + 60-m1 + (h2-1-h1) * 60;} int time (int h, int m) {// convert to minute return h * 60 + m;} int Judge (int h1, int m1, int h2, int m2) {// filter time occupied int s1, s2, res = 0; s1 = time (h1, m1); s2 = time (h2, m2 ); // cout <