leetcode在力扣 App 中打开
题目描述
题目描述
题解
题解
提交记录
提交记录
代码
代码
测试用例
测试用例
测试结果
测试结果
简单
premium lock icon相关企业

It has been a year since Noel joined Shopee. Like every ordinary day, before starting daily work, Noel will go to the pantry and make a cup of coffee for himself.

A box of length N is placed next to the coffee machine in the pantry, and coffee beans of different flavors are placed in a row. Noel has his own taste preference value V[i] for each type of coffee bean. Noel has a habit of his own, that is, every time he will select coffee beans in consecutive boxes (assuming that each flavor of coffee beans is unlimited supply) and put them into the coffee machine to get a cup of mixed coffee whose taste preference value V will be the average value of the chosen flavors. A cup of mixed coffee will be called Shoffee if its taste preference value V is not less than K , Shoffee can quickly wake Noel up. Noel hopes that every day he can drink a cup of Shoffee and keep himself in a good working status. Please help him calculate how many types of Shoffee can be in total.

Input Format Each test case will consist of exactly 2 lines. The first line are two positive integers N (1 <= N <= 10^5) and K (1 <= K <= 10^4) splitted by space, representing the number of coffee bean flavors, and Noel’s expectation for the coffee. The second line contains N positive integers V[i] (1 <= V[i] <= 10^4) splitted by space, representing Noel’s preference value for each type of coffee bean.

Output Format For each test case, please output an answer in one line representing the number of Shoffee can be in total.

Sample Input Case 1:

3 3
1 3 4

Case 2:

6 3 
1 1 4 5 1 4

Sample Output Case 1: 3

Case 2: 10

Explanation For the first test case, there are totally N=6 different consecutive sequences: (1),(3),(4),(1,3),(3,4),(1,3,4), and their average values are V = 1, 3, 4, 2, 3.5, 8/3. Among these, there will be 3 numbers greater than or equal to K = 3 , so the answer will be 3.

通过次数
299/650
通过率
46.0%

icon
相关企业

评论 (0)
💡 讨论区规则

1. 请不要在评论区发表题解!

2. 评论区可以发表关于对翻译的建议、对题目的疑问及其延伸讨论。

3. 如果你需要整理题解思路,获得反馈从而进阶提升,可以去题解区进行。

暂无评论

贡献者
© 2025 领扣网络(上海)有限公司
0 人在线
行 1,列 1
Source