HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


50748 - Gold Store

Guest
• Review clarifications (2)

Volume problems

• 51043 - Genome Sequencing
• 51042 - The most frequent k-mer
• 50657 - Permutations and Combinat...
• 51246 - Swap largest word, reverse ...
• 51069 - Last Digit of a Fibonacci Nu...
• 50659 - Covariance Matrix
• 50977 - Gaussian Elimination
• Word Puzzle
• 50748 - Gold Store
• 50658 - The Message
• 50766 - Word Puzzle
• 50934 - Selling Cars
• 50746 - Most Visited
• 50749 - Min Distance
• 50915 - Trip to Korca
• 50985 - Books Waiting
• 50927 - Health Expenses

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.

Gold Store

You work in a Gold Store. Every item in the store has different weight and price. And, you have two safe deposit boxes. The first safe box is stronger than the other one and it can properly hold at most m items.

Because everyday several items are sold and several other new items arrive to the store, you want to write a program which decides what items to choose for the first safe box. Items are put in descending order according to their price per unit weight. If two items have the same unit price, then the item with the smaller id is before the other one.

Question: Write a program that is going to read n item information, then it will show top m items to store in the first safe box.

Input specification
You will be given two integers (n and m) the number of items and top m items to show where 0 ≤ n, m ≤ 3000. Then, in the following n lines you will be given three information for each item:

  • ID: an integer between 1 and 1e6
  • Weight: an integer between 1 and 1e5
  • Price: an integer between 0 and 1e8

Output specification
Show the ID and unit price of top m items.

Sample Input I
3 3
1 20 100
2 10 60
3 30 120
Sample Output I
2 6
1 5
3 4



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

www.contester.ru