ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Турниры > CEN112 Questions 2016 > задача:


15-HW-4. 50934 - Selling Cars

CEN112 Questions 2016

Старт: 30.мар.2016 в 15:10:22
Финиш: 01.апр.2016 в 05:00:00
Турнир завершён!
• Турнирная таблица

Гость
• Вопросы к жюри (5)

Задачи турнира

• 15-FE-2. 50993 - Products in store
• 15-FE-3. 50994 - The Most Crowded...
• 15-FE-4. 50995 - Group Average
• 15-FE-6. 50989 - Rectangles and Points
• 15-FE-7. 50990 - Two Neighbors
• 15-FE-8. 50991 - Intersecting Circles
• 15-HW-2. 50932 - Shifting rows and...
• 15-HW-3. 50933 - Sum of the Bigges...
• 15-HW-4. 50934 - Selling Cars
• 15-HW-5. 50935 - Max Discount
• 15-MdtE-1. 50915 - Trip to Korca
• 15-MdtE-2. 50916 - Ascending Num...
• 15-MdtE-3. 50913 - Manhattan Distance
• 15-MdtE-4. 50917 - Descending Nu...
• 15-MdtE-5. 50912 - Trip to Librazhd
• 15-MdtE-6. 50914 - Buy 3, Pay 2
• 15-PE-1. 50865 - Apartment Building...

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Selling Cars

Question: Your friend has an internet site to sell cars. For faster searches, he asks from you to write a program. There are two types of searches:

  • Maker, year and price
  • Year, mileage up to and price
You will be given the database. And then, you will be given the search type. Show top m items complying the given criteria.

Input specification
You will be first given an integer (n) the number of cars in the database. The following n lines contains:

  • Unique car ID: an integer less than 1 billion
  • Car maker: string not more 15 chars ending with a semicolon
  • Year: a four-digit integer
  • Motor: at most 20 chars string ending with a semicolon
  • Mileage: integer less than a billion
  • Price: a floating point number less than 50 million
Then, you will be given search type and an integer (m) and search criteria. If search type is
  1. You will be given:
    • Car maker (ending with a semicolon),
    • Year: list the cars which are produced on or before the given year,
    • Price: list the cars which are cheaper than or equal to the price.
  2. You will be given:
    • Year: list the cars which are produced on or before the given year,
    • mileage up to: list the cars whose mileage is smaller than or equal to the given value,
    • Price: list the cars which are cheaper than or equal to the price.
where 0 ≤ m ≤ n ≤ 20,000

Output specification:
If searchtype 1 is chosen, list the cars in descending order according to price and then year.
If searchtype 2 is chosen, list the cars in descending order according to price. If there are several cars with the same price, show in ascending order according to mileage and then year. Note: If there are less cars than m, show all cars that comply the given criteria.

Sample Input I
8
5 Toyota; 2016 Electric; 4700 20935.7
11 Lexus; 2015 Petrol; 9900 36213.8
14 Land Rover; 2015 Diesel; 9400 30060
19 Volkswagen; 2014 Diesel; 15600 16200
21 Volkswagen; 2016 Petrol; 4200 18250
25 Lotus; 2014 Electric; 16600 29989.2
31 Cadillac; 2015 LPG; 9300 28450
36 Toyota; 2012 Petrol; 32000 34430
1 2 Volkswagen; 2016 20000
Sample Input II
8
5 Toyota; 2016 Electric; 4700 20935.7
11 Lexus; 2015 Petrol; 9900 36213.8
14 Land Rover; 2015 Diesel; 9400 30060
19 Volkswagen; 2014 Diesel; 13600 16200
21 Volkswagen; 2016 Petrol; 4200 18250
25 Lotus; 2014 Electric; 13600 19989.2
31 Cadillac; 2015 LPG; 9300 8450
36 Toyota; 2012 Petrol; 12000 7430
2 5 2015 15000 20000
Sample Output I
18250 2016
16200 2014
Sample Output II
19989.20 13600 2014
16200.00 13600 2014
8450.00 9300 2015
7430.00 12000 2012

Explanation: Search type 1 is chosen and top 2 cars will be listed. There are Cars from the given car model: Volkswagen. And both of them are listed according to given criteria.



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

www.contester.ru