#K13521. Taco Serving Dilemma
Taco Serving Dilemma
Taco Serving Dilemma
You are given n friends, each with a preferred taco dish. There are k types of tacos available and a restriction that no taco type can be served more than q times. Determine whether it is possible to serve every friend their preferred taco without exceeding the serving limit for any type.
Formally, let \( n \) be the number of friends, \( k \) be the number of taco types, and \( q \) be the maximum allowed servings per taco. The preferences of the friends are provided as a list of integers. You need to check if the frequency of each taco type is \( \leq q \). Output YES if all counts are within the limit; otherwise, output NO.
inputFormat
The first line contains three integers ( n ), ( k ), and ( q ) separated by spaces, where:
- ( n ) is the number of friends,
- ( k ) is the number of taco types, and
- ( q ) is the maximum number of times any taco can be served. The second line contains ( n ) integers, where each integer represents the preferred taco type of a friend.
outputFormat
Output a single line containing YES if it is possible to serve each friend their preferred taco without exceeding the serving limit; otherwise, output NO.## sample
6 3 2
1 2 3 1 2 3
YES