|
Лимит времени 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
- 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.
- 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.
Для отправки решений необходимо выполнить вход.
|