Will the Second IUPC Go Well?
InterviewTime limit1sMemory limit128 MB
Given the pen counts of N members, find the fewest members whose pens total at least M*K, or print STRESS if the total falls short.
- Level
Easy3 of 10
- Topics
- Greedy, Sorting, Array, Implementation
- Solved
- No attempts yet
Problem
The second Inha University Programming Contest (IUPC) is held on May 28, 2016. Unlike other programming contests, this one is solved by writing code on paper, so every contestant needs a pen. Jeongeun, the president of CTP, wants to hand a pen to each contestant. To save contest budget she borrows the pens from CTP members instead of buying new ones.
CTP has members, and no two members carry the same number of pens in their pen case. Returning pens to many people afterwards is a nuisance, so Jeongeun borrows from as few members as possible. When she borrows from a member, she takes every pen that member has.
teams enter the contest and each team consists of people. Every team member gets one pen, so pens are needed. Find the smallest number of members Jeongeun has to borrow from in order to collect that many pens.
Input
The first line contains the number of CTP members ().
The second line contains the number of teams () and the number of members on one team (), separated by a space.
The third line contains integers separated by spaces, where () is the number of pens one member has.
Output
Print the smallest number of members Jeongeun has to borrow from, on one line. If there are not enough pens to supply every team member, print STRESS without the quotation marks.