시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB91252225.287%

문제

You are a programming coach at a university. Your university is registering several teams to participate in a programming contest. The programming contest is participated by teams of three programmers.

In your university, there are $N$ eligible programmers, numbered from $0$ to $N - 1$. For each $i$ such that $0 ≤ i ≤ N - 1$, programmer $i$ has a skill level of $L[i]$. The skill level of a team consisting of programmer $i$, $j$, and $k$ is $\min{(L[i],L[j],L[k])} + \max{(L[i],L[j],L[k])}$.

You want to only register teams with a skill level of strictly more than $K$. Each programmer may only be assigned to at most one registered team. You want to know the maximum number of teams you can register.

구현

You should implement the following procedure:

int maximum_teams(int N, int K, int[] L);
  • $N$: the number of programmers.
  • $K$: the skill level limit of the registered teams.
  • $L$: an array of length $N$ describing the skill level of the programmers.
  • This procedure should return the maximum number of teams you can register.
  • This procedure is called exactly once.

예제

Consider the following call:

maximum_teams(8, 6, [5, 4, 6, 2, 3, 2, 1, 1])

You can register a team with programmer $0$, $3$, and $5$ (with skill levels $5$, $2$, $2$ respectively) and a team with programmer $1$, $2$, and $4$ (with skill levels $4$, $6$, $3$ respectively). There is no way to register more than two teams. Therefore, the procedure maximum_teams should return $2$.

제한

  • $1 ≤ N ≤ 100\,000$
  • $ 1 ≤ K ≤ 10$
  • $ 1 ≤ L[i] ≤ 10$ (for each $i$ such that $0 ≤ i ≤ N - 1$)

서브태스크

번호배점제한
16

$N ≤ 3$

212

$N ≤ 8$

337

$N ≤ 1000$

445

No additional constraints.

샘플 그레이더

The sample grader reads the input in the following format:

  • line $1$: $N$ $K$
  • line $2$: $L[0]$ $L[1]$ $\dots$ $L[N - 1]$

The sample grader prints your answer in the following format:

  • line $1$: the return value of maximum_teams

첨부

제출할 수 있는 언어

C++17, C++20, C++17 (Clang), C++20 (Clang)

채점 및 기타 정보

  • 예제는 채점하지 않는다.