#QHD0000069. Trả tiền vừa đủ hoặc hơn (Exact Change)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Trả tiền vừa đủ hoặc hơn (Exact Change)
Exact Change
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
An item costs cents. You own individual coins or banknotes; note has value and may be used at most once. The seller cannot give change, so the payment must total at least . First minimize the total amount paid; among solutions paying the same amount, minimize the number of notes used. The total value of all available notes is guaranteed to be at least .
Input
The first line contains the price . The second line contains . Each of the next lines contains a note value .
Output
Print two integers: the minimum amount paid and the minimum number of notes needed to pay exactly that amount.
Subtasks
The independent scoring groups have the following complete constraints:
- Subtask 1 (20%): , , , .
- Subtask 2 (30%): , , , .
- Subtask 3 (50%): , , , .
Examples
Input
1400
3
500
1000
2000
Output
1500 2
Explanation
Using the and bills pays with bills. No subset totals between and , so is the minimum payment, achieved with the minimum of bills.