Input The input consists of: • one line with two integers n (1 ≤ n ≤ 300 000), the number of researchers, and m (1 ≤ m ≤ 10%), the number of minutes of inactivity after which a workstation locks itself; • n lines each with two integers a and s (1 ≤ a, s ≤ 108), representing a researcher that arrives after a minutes and stays for exactly s minutes. Output Output the maximum number of unlockings Penelope may save herself. Sample Input 1 Sample Output 1 35 1 5 63 14 6 Sample Input 2 Pa 2 Sample Output 2 2 Pa

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

CODE IN JAVA.

Penelope is part of the admin team of the newly built supercomputer. Her job is to assign workstations to the researchers who come here to run their computations at the supercomputer.

Input
The input consists of:
• one line with two integers n (1 ≤ n ≤ 300 000), the number of researchers,
and m (1 ≤ m ≤ 10%), the number of minutes of inactivity after which a
workstation locks itself;
• n lines each with two integers a and s (1 ≤ a, s ≤ 108), representing a
researcher that arrives after a minutes and stays for exactly s minutes.
Output
Output the maximum number of unlockings Penelope may save herself.
Sample Input 1
Sample Output 1
35
1 5
63
14 6
Sample Input 2
5 10
26
1 2
17 7
39
15 6
N
2
Sample Output 2
3
2
Transcribed Image Text:Input The input consists of: • one line with two integers n (1 ≤ n ≤ 300 000), the number of researchers, and m (1 ≤ m ≤ 10%), the number of minutes of inactivity after which a workstation locks itself; • n lines each with two integers a and s (1 ≤ a, s ≤ 108), representing a researcher that arrives after a minutes and stays for exactly s minutes. Output Output the maximum number of unlockings Penelope may save herself. Sample Input 1 Sample Output 1 35 1 5 63 14 6 Sample Input 2 5 10 26 1 2 17 7 39 15 6 N 2 Sample Output 2 3 2
Problem A
Assigning Workstations
Penelope is part of the admin team of the
newly built supercomputer. Her job is to
assign workstations to the researchers
who come here to run their computations
at the supercomputer.
<Hide
Picture by NASA via Wikimedia Commons
Penelope is very lazy and hates unlocking
machines for the arriving researchers. She
can unlock the machines remotely from
her desk, but does not feel that this menial
task matches her qualifications. Should she decide to ignore the security
guidelines she could simply ask the researchers not to lock their workstations
when they leave, and then assign new researchers to workstations that are not
used any more but that are still unlocked. That way, she only needs to unlock each
workstation for the first researcher using it, which would be a huge improvement
for Penelope.
Unfortunately, unused workstations lock themselves automatically if they are
unused for more than m minutes. After a workstation has locked itself, Penelope
has to unlock it again for the next researcher using it. Given the exact schedule of
arriving and leaving researchers, can you tell Penelope how many unlockings she
may save by asking the researchers not to lock their workstations when they leave
and assigning arriving researchers to workstations in an optimal way? You may
assume that there are always enough workstations available.
Input
The input consists of:
Transcribed Image Text:Problem A Assigning Workstations Penelope is part of the admin team of the newly built supercomputer. Her job is to assign workstations to the researchers who come here to run their computations at the supercomputer. <Hide Picture by NASA via Wikimedia Commons Penelope is very lazy and hates unlocking machines for the arriving researchers. She can unlock the machines remotely from her desk, but does not feel that this menial task matches her qualifications. Should she decide to ignore the security guidelines she could simply ask the researchers not to lock their workstations when they leave, and then assign new researchers to workstations that are not used any more but that are still unlocked. That way, she only needs to unlock each workstation for the first researcher using it, which would be a huge improvement for Penelope. Unfortunately, unused workstations lock themselves automatically if they are unused for more than m minutes. After a workstation has locked itself, Penelope has to unlock it again for the next researcher using it. Given the exact schedule of arriving and leaving researchers, can you tell Penelope how many unlockings she may save by asking the researchers not to lock their workstations when they leave and assigning arriving researchers to workstations in an optimal way? You may assume that there are always enough workstations available. Input The input consists of:
Expert Solution
steps

Step by step

Solved in 2 steps with 12 images

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education