Voyage
Time limit1sMemory limit1024 MB
Given N sandwiches, cut meals of length X to Y cm from them to maximize the meal count, then minimize the total length of discarded remainders.
- Level
Medium6 of 10
- Topics
- Greedy, Sorting, Binary search
- Solved
- No attempts yet
Problem
Junwon starts a voyage today. The only food Junwon has is Subway sandwiches. The length of the -th sandwich is cm.
At each meal, Junwon cuts a little from one of the sandwiches. Specifically, he picks one of the sandwiches and cuts off a piece whose length is at least cm and at most cm. If the remainder after cutting is less than cm, Junwon throws it away. (Junwon does not do shabby things like combining several small pieces to eat.)
Using the sandwiches he has, find the maximum number of meals Junwon can solve. Then, after solving that many meals, find the minimum possible total length of the discarded sandwich pieces.
Input
The first line contains , , and , separated by spaces.
The second line contains the lengths , separated by spaces.
Output
The first line prints the maximum number of meals Junwon can solve.
The second line prints the minimum total length of the discarded sandwich pieces.
Constraints
- For each (), .