HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Linear Data Structures: Arrays > problem:


50925 - Optimizing Elevator Usage

Guest
• Review clarifications (2)

Section problems

• 50525 - Ordering Pizza
• 51099 - Mr. Monk
• 50468 - Draw Matrix - 2
• 51096 - Guess the number - 2
• 50448 - Paint Buckets
• 50988 - Laplacian Filter
• 50269 - Matrix Determinant
• 50986 - The Oldest Person
• 50925 - Optimizing Elevator Usage
• 51173 Question 5
• 50334 - What is the class average?
• 50873 - Max Frequency
• 51009 - Sum of the nth row
• ECE - Question 1
• CEN - Question 1
• 51107 - Factorial
• Reflektimi i pikes

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Optimizing Elevator Usage

In the mornings, many people want to leave building and in the evenings many people come to the building to go for upper floors. So, you want to optimize the waiting time for people according to the given precision. In a file you have recorded the elevator floor numbers and their request times. For example, if hourly precision is selected and if many people ask elevator from the floors 10 and 12 between 8:00 and 09:00, it’s better if the elevator is close to these floors on its free times, so that the elevator can serve faster.

Question: Write a program that reads the usage information for the elevator, and the precision. Then, show the waiting floors for the given hours.

Input specification:
You will be given first:

  • The number of usage entries (n): an integer between 1 and 10,000
  • Precision asked: an integer between 2 and 720, a perfect divisor of 720 where 2 means 2 minutes precision. 60 means hourly precision.
Then, the following n lines will contain three integers: floor requesting the elevator, hour and minute of the request. The next line has an integer: the number of hours for which the waiting floors asked (m): between 1 and 200. The following m lines contain two integers: hour and minute for which you will print the waiting floors.
Note: You will round the floor numbers to the nearest integer.

Output specification:
Show m integers. If there is no information provided for the given hour and minute, print 0.

Sample Input I
5 60
16 11 22
9 7 27
4 9 53
16 7 7
14 11 50
2
11 25
7 55
Sample Output I
15
13

Explanation: Hourly precision is selected. And, two times are asked: at 11:25 and 7:55. There are two usage information provided between 11 and 12. At 11:22, the elevator was asked from floor 16 and and at 11:50, it was asked from floor 14. So, according to the current usage schema, because many people close to floor 15 are using it, it is better the elevator to stay on floor 15 on its free times between 11 and 12.



Для отправки решений необходимо выполнить вход.

www.contester.ru