Question: Juan Marquinho is a geologist and he needs to count rock samples in order to send to a chemical laboratory. He has a problem: The laboratory only accepts rock samples by a rar of its size in ppm (parts per million). Juan Marquinho receives the rock samples one by one and he classifies the rock samples according to the range of the laboratory. This process is very hard because the number of rock

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
Question
39. Need C, C++, Java, Python, or Perl code for the below question. Important: Do not copy codes from prepinsta.com.
Question: Juan Marquinho is a geologist and he needs to count rock samples in order to send it
to a chemical laboratory. He has a problem: The laboratory only accepts rock samples by a range
of its size in ppm (parts per million).
Juan Marquinho receives the rock samples one by one and he classifies the rock samples
according to the range of the laboratory. This process is very hard because the number of rock
samples may be in millions.
Juan Marquinho needs your help, your task is to develop a program to get the number of rocks in
each of the ranges accepted by the laboratory.
Input Format
An positive integer S (the number of rock samples) separated by a blank space, and a positive
integer R (the number of ranges of the laboratory); A list of the sizes of S samples (in ppm), as
positive integers separated by space R lines where the ith line containing two positive integers,
space separated, indicating the minimum size and maximum size respectively of the ith range.
Output Format
R lines where the ith line contains a single non-negative integer indicating the number of the
samples which lie in the ith range.
Constraints
. 10<S< 10000
. 1<R< 1000000
• 1 size of each sample (in ppm) < 1000
Example 1
Input: 10 2
345 604 321 433 704 470 808 718 517 811
300 350
400 700
Output: 24
Explanation:
There are 10 samples (S) and 2 ranges (R). The samples are 345 604 321 433 704 470 808 718 517
811. The ranges are 300-350 and 400-700. There are 2 samples in the first range (345 and 321)
and 4 samples in the second range (604, 433, 470, 517). Hence the two lines of the output are 2
and 4
Transcribed Image Text:Question: Juan Marquinho is a geologist and he needs to count rock samples in order to send it to a chemical laboratory. He has a problem: The laboratory only accepts rock samples by a range of its size in ppm (parts per million). Juan Marquinho receives the rock samples one by one and he classifies the rock samples according to the range of the laboratory. This process is very hard because the number of rock samples may be in millions. Juan Marquinho needs your help, your task is to develop a program to get the number of rocks in each of the ranges accepted by the laboratory. Input Format An positive integer S (the number of rock samples) separated by a blank space, and a positive integer R (the number of ranges of the laboratory); A list of the sizes of S samples (in ppm), as positive integers separated by space R lines where the ith line containing two positive integers, space separated, indicating the minimum size and maximum size respectively of the ith range. Output Format R lines where the ith line contains a single non-negative integer indicating the number of the samples which lie in the ith range. Constraints . 10<S< 10000 . 1<R< 1000000 • 1 size of each sample (in ppm) < 1000 Example 1 Input: 10 2 345 604 321 433 704 470 808 718 517 811 300 350 400 700 Output: 24 Explanation: There are 10 samples (S) and 2 ranges (R). The samples are 345 604 321 433 704 470 808 718 517 811. The ranges are 300-350 and 400-700. There are 2 samples in the first range (345 and 321) and 4 samples in the second range (604, 433, 470, 517). Hence the two lines of the output are 2 and 4
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Maximum Flow
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
  • SEE MORE 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