Cat Cafe
InterviewTime limit2sMemory limit1024 MB
Pair up cats so each pair's total weight is at most K, and find the maximum number of pairs that can be formed.
- Level
Easy3 of 10
- Topics
- Sorting, Two pointers, Greedy
- Solved
- No attempts yet
Problem
Chanwoo is going to a cat cafe with his friends.
The cat cafe has cats. The weight of the -th cat is . Chanwoo and his friends all love cats, so each person becomes happy when they hold exactly cats on their lap. However, Chanwoo and his frail friends cannot hold up if the total weight of the two cats they hold exceeds .
Given the weight of each cat and the maximum weight that one person can bear, find the maximum number of people who can be happy.
Input
The first line contains integers and , separated by a space. (; )
The second line contains integers , separated by spaces. ()
Output
Print the maximum number of people who can be happy.