HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Sorting and sequences > problem:


50347 - Selling Oranges

Guest
• Review clarifications (1)

Section problems

• 50744 - The Smallest Perimeter
• 50743 - Total Scholarships Discount
• 50984 - Top m hardworking employees
• 50847 - The first m trains to leave
• 51002 - The most successful classes
• Word Puzzle
• 50740 - Service Time - 1
• 50750 - Service Time - 2
• 50347 - Selling Oranges
• 50758 - National Elections - Revisited
• 50754 - Team Standings
• 50358 - Series of Odd Numbers
• 50756 - Average of the Nth Student
• 50757 - National Elections - 1
• 50755- Top N Donors - 1
• 50752 - Student Groups
• 50753 - Average of the Nth Student

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.

Selling Oranges

Mr. Ilir Dardani produces oranges and export them. When exporting he puts the oranges into bins (buckets) according to their sizes. Thus according to their sizes the prices change.

The size of oranges vary, usually upto 15cms. They are put into m bins with the sizes b1, b2, b3..., bm. And it's known that the bin sizes are in increasing order. An orange fits into bini if its size is greater than or equal to bini but is less than bini+1. Mr. Dardani wants to put all oranges to the biggest bin that they fit.

Question:
Write a program that is going to read bin and orange information and calculate the total sell price.

Input specification
There are two numbers at the beginning: the number of bins (m) and the number of oranges (n) where 1 ≤ m ≤ 10 and 1 ≤ n ≤ 50000. The following m lines give the size of bins followed by price of each orange in that bin, whe size of bins are between 1 and 15 and price of each orange is $0.10 and $2.50. The following line gives n positive floating point numbers between 1 and 15.

Output specification
Show the total sell price.

Sample Input I
  3 6
  1 0.3
  6 0.8
  12 1.5
  12.4 6.8 14 5 4.7 9
Sample Input II
  5 10
  1 0.3
  3 0.5
  6 0.8
  9 1
  12 1.5
  5 3 8.2 9.1 6 9 1 10 15 4.6
Sample Output I
  5.2
Sample Output II
  7.9


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

www.contester.ru