PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000011. Chú voi và tần suất bằng giá trị (Little Elephant and Array)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Chú voi và tần suất bằng giá trị (Little Elephant and Array)
Little Elephant and Array
Source: Codeforces Version: Phuoc Hung OJ Extended
Problem Statement
For a query range , call an integer value good if its frequency in that range is exactly . For each query, count how many different values are good. For example, a value of that appears exactly three times contributes one.
Input
The first line contains . The second line has positive integers . The next lines contain .
Output
Print lines, one answer per query in the original order.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input
7 2
3 1 2 2 3 3 7
1 7
3 4
Output
3
1
Explanation
In , value occurs once, value twice, and value three times, so there are good values.