#P15091. [UOI 2025 II Stage] Catamarans
[UOI 2025 II Stage] Catamarans
题目描述
A group of people plans to go for a ride on catamarans.
As the leader of the group, you have been tasked with ordering the catamarans. You know that one catamaran can hold a weight of no more than kilograms, and you also know the weight of each group member.
You are aware that in your group, a person can weigh either , , , , or kilograms.
To spend as little money as possible, you decided to write a program that calculates the minimum number of catamarans needed.
输入格式
The first line contains one integer ~--- the number of people in the group.
The second line contains integers ~--- the weight of each person.
输出格式
Output one integer --- the minimum number of catamarans needed.
4
20 40 80 80
3
4
20 40 20 20
1
提示
In the first example, we can seat the first two people in one catamaran, the third person in the second catamaran, and the fourth person in the third catamaran. We cannot seat everyone in two catamarans because person cannot sit with person or , and person cannot sit with person either.
In the second example, we can seat everyone in one catamaran because their total weight is equal to kilograms, which means the catamaran can hold them.