IV Olimpiada Informatyczna 1996/1997
|
Task: KAJ
|
Author: Wojciech Rytter
|
III stage contest |
Source file | KAJ.??? (e.g. PAS,C, CPP) |
Executable file | KAJ.EXE |
Input file | KAJ.IN |
Output file | KAJ.OUT |
We are organizing a canoe tour. Canoes can be hired at the harbour. Canoes are all alike. A canoe can take at most two persons. The sum of weights of these persons cannot exceed the fixed maximal weight. We want to pay as little as possible so we should try to place all participants of our tour in the minimal number of canoes.
In the second line there is one integer n, 1 <= n <= 30000, which is the number of participants of the tour.
Each of the following n lines contains one integer from the range [5..w]. These numbers equal the weights of the participants.
Example
For the text file KAN.IN:
100 9 90 20 20 30 50 60 70 80 90the correct result is the text file KAJ.OUT:
6