Problem N
Global Warming
This is a very exciting week for John. The reason is that,
as a middle school teacher, he has been asked to dedicate the
entire week to teaching his class of
Of course arranging the students into groups comes with the
usual headache, namely that only friends are willing to work
together. Luckily the students in his class are a friendly
bunch. In particular, if
Using this information, can you help John figure out what is the minimum total amount of carbon dioxide that will be emitted if he arranges the groups optimally, or determine that it’s not possible to arrange all the students into groups of two friends?
Input
The first line contains two integers
Each of the next
Output
Output the minimum total amount of carbon dioxide, in grams, that would be emitted if John arranges all students optimally into groups of two friends, or “impossible” if there is no way to arrange the students into groups in that way.
Sample Input 1 | Sample Output 1 |
---|---|
5 4 3 1 375 2 5 283 1 4 716 3 4 98 |
impossible |
Sample Input 2 | Sample Output 2 |
---|---|
6 7 5 6 600 2 5 200 3 5 400 6 3 500 1 4 300 3 2 400 6 2 200 |
900 |