logo AlgoBeat OnlineJudge
登录 注册

#215224. [UOI 2025 II Stage] Catamarans

内存限制:512 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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.

样例

样例输入 1

4
20 40 80 80

样例输出 1

3

样例输入 2

4
20 40 20 20

样例输出 2

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.