#P12315. Maximizing Apples Distribution
Maximizing Apples Distribution
Maximizing Apples Distribution
In a classroom, the teacher plans to distribute apples among students. There are ( n ) types of apples, and the deliciousness value of the ( i )-th type is ( a_i ). Each student must choose a non-negative integer ( x ), and the student will receive one apple of each type that satisfies ( ((a_i + x) \bmod k) \leq t ). Blue secretly learns the values of ( k ) and ( t ) using magic. Your task is to determine the maximum number of apples Blue can obtain by choosing an appropriate ( x ).
inputFormat
The first line contains three integers ( n ), ( k ), and ( t ) (where ( 1 \leq n \leq 10^5 ), ( 1 \leq k \leq 10^5 ), and ( 0 \leq t < k )). The second line contains ( n ) integers ( a_1, a_2, \dots, a_n ) representing the deliciousness values of the apples.
outputFormat
Output a single integer representing the maximum number of apples Blue can receive by choosing an appropriate non-negative integer ( x ).
sample
5 5 2
0 1 2 3 4
3