PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000044. Đếm đoạn có trung bình không nhỏ hơn K (Meaningful Mean)
HỌC THEO LỘ TRÌNH
3 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm đoạn có trung bình không nhỏ hơn K (Meaningful Mean)
Meaningful Mean
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers and , count the nonempty contiguous subarrays whose arithmetic mean is at least . Different positions count separately.
Input
The first line contains . The next integers are (one per line in the original format).
Output
Print the number of subarrays whose mean is at least .
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
3 6
7
5
7
Output
5
Explanation
There are six subarrays; only has mean below 6, hence the answer is 5.