Сортировка и жадность - 2
Water
Recently Sergey went to the well for water but did not return. He took n cans with him, each of which he filled completely with water. Now Sergey wants to deliver them to his country house. This is where the problem lies. At one time Sergey can carry no more than 2 cans because he has only two hands. Moreover, he can carry no more than k liters of water.
Now Sergey stands at the well and thinks about the minimum number of times he can take all the water home, and whether he can do it at all. Help him solve this problem.
Input data
The first line contains two integers n and k (1 ≤ n ≤ 10^5
). The second line contains n integers - the volumes of canisters in liters. All input numbers are positive and do not exceed 10^9
.
Output data
If Sergey cannot take all the water home, print "Impossible". Otherwise, print one number - the minimum required number of times to go.
Examples
4 4 1 2 3 3
3