2023 Huawei OD Machine Examination Paper B Language C Implementation [Maximum Teams]

Table of contents

topic

Ideas

test center

Code


topic

Use an array to represent the ability of each person. A competition requires the minimum ability value of the participating team to be N. Each team can be composed of 1 or 2 people, and one person can only participate in one team. Please calculate the maximum number that can be sent A team that meets the requirements?

Input description:
5
3 1 5 7 9
8
The array in the first line represents the total number of people, the range is [1,500000], the
array in the second line represents the ability of each person, the value range of each element is [1, 500000], and the size of the array The value in the third line of range [1, 500000]
is the minimum ability value required by the team. Range [1, 500000]
output description:
3
The maximum number of teams that can be dispatched
Example 1 :

Input
5
3 1 5 7 9
8
and output
3
means that
3 and 5 form a team, 1 and 7 form a team, and 9 is on its own team, so the output is 3

Example 2:

enter

Guess you like

Origin blog.csdn.net/misayaaaaa/article/details/132776074