#GD0000139. Phân giỏ hàng để được giảm giá (Discounts)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Phân giỏ hàng để được giảm giá (Discounts)
Discounts
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A store sells items, item priced and having type : type is a stool, type is a pencil. Buy every item using exactly nonempty shopping carts, placing each item in exactly one cart. A cart containing at least one stool gets 50% off exactly one cheapest item in that cart; carts with no stool receive no discount. Print the minimum total cost and any optimal partition.
Input
The first line contains . Each of the next lines contains . Items are indexed through in input order.
Output
Print the minimum price with exactly one digit after the decimal point. Then print exactly lines: followed by the item indices in cart . Every cart is nonempty and each item appears once.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
3 2
2 1
3 2
3 1
Output
5.5
1 3
2 1 2
Explanation
Put item (a stool priced ) alone in the first cart, paying . Put items (a stool) and (a pencil) in the second cart: the cheapest item is reduced to , so this cart costs . Total payment is .