HUAWEI OD machine test - Rent a car and ride on Green Island (JAVA, C, C++, GO, Python, JavaScript)

Huawei OD machine test questions rent a car and ride Green Island, JAVA & Python & C & C++ & GO & JavaScript

topic

The department organizes green island cycling team building activities. Rent public tandem bicycles for riding, each bicycle can seat up to two people, and carry a large load M.
Given the weight of each person in the department, what is the maximum number of tandem bicycles that can be rented.

enter

The two numbers m and n in the first line, the bicycle weight limit m, represent the total number of people in the department n.
In the second line, n numbers represent the weight of each person. The weight is less than or equal to the bicycle weight limit m.
0 < m <= 200
0 < n <= 1000000

output

Minimum number of tandem bicycles required.

example one

enter

3 4
3 2 2 1

output

3

JAVA code implementation

import java.util.

Guess you like

Origin blog.csdn.net/jiong9412/article/details/130288389