HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Sorting and sequences > problem:


50347 - Selling Oranges

Guest
• Review clarifications (1)

Section problems

• 50311 - Student Line Up
• 50736 - Top N Donors - 2
• 50333 - Series of Squares
• 50734 - Product Info (In Srt)
• 50364 - Student averages
• 50733 - The Highest Average
• 50358 - Series of Odd Numbers
• 50756 - Average of the Nth Student
• 50347 - Selling Oranges
• 50758 - National Elections - Revisited
• 50757 - National Elections - 1
• 50755- Top N Donors - 1
• 50290 - Minimax Sum
• 50339 - The Largest Rectangle
• 50753 - Average of the Nth Student
• 50735 - Top M Products
• 50361 - Align Two Lists

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