#P10389. [蓝桥杯 2024 省 A] 成绩统计

[蓝桥杯 2024 省 A] 成绩统计

Problem Description

There are nn students in Xiao Lan's class. After an exam, Xiao Lan wants to analyze the students' scores. The score of the ii-th student is aia_i. After Xiao Lan has checked the scores of the first xx students, he can choose any kk students from 1x1 \sim x and compute the variance of these kk scores. What is the minimum number of students' scores Xiao Lan must check so that it is possible to choose kk students whose variance is less than a given value TT?

Hint: The variance σ2\sigma^2 of kk numbers v1,v2,,vkv_1, v_2, \cdots , v_k is defined as σ2=i=1k(vivˉ)2k\sigma^2=\dfrac {\sum_{i=1}^k(v_i-\bar v)^2} k, where vˉ\bar v is the average of viv_i, vˉ=i=1kvik\bar v = \dfrac {\sum_{i=1}^k v_i} k.

Input Format

The first line contains three positive integers n,k,Tn, k, T, separated by one space.

The second line contains nn positive integers a1,a2,,ana_1, a_2, \cdots, a_n, separated by one space.

Output Format

Output one line containing one integer, the answer. If the condition cannot be satisfied, output 1-1.

5 3 1
3 2 5 2 3
4

Hint

After checking the scores of the first three students, you can only choose 3,2,53, 2, 5, and the variance is 1.561.56.

After checking the scores of the first four students, you can choose 3,2,23, 2, 2, and the variance is 0.22<10.22 < 1, so the answer is 44.

Constraints:

For 10%10\% of the testdata, 1n,k1021 \le n, k \le 10^2.

For 30%30\% of the testdata, 1n,k1031 \le n, k \le 10^3.

For all testdata, 1n,k1051 \le n, k \le 10^5, 1T23111 \le T \le 2^{31} -1, 1ain1 \le a_i \le n.

Translated by ChatGPT 5