PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000074. Các giá trị thường gặp (Frequent values)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Các giá trị thường gặp (Frequent values)
Frequent values
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
The given integer sequence is sorted in nondecreasing order. For each inclusive range , report the maximum number of occurrences of a single value within the range (not the value itself).
Input
Read , a nondecreasing array, and inclusive queries. There is no sentinel terminator.
Output
Print the maximum occurrence count for every range.
Subtasks
- Subtask 1 (10 points): , . ; ; .
- Subtask 2 (20 points): , . ; ; .
- Subtask 3 (25 points): , . ; ; .
- Subtask 4 (45 points): , . ; ; .
Examples
Input
10 3
-1 -1 1 1 1 1 3 10 10 10
2 3
1 10
5 10
Output
1
4
3
Explanation
Range has maximum frequency 1. The whole array has four consecutive 1s, giving 4. Range contains two 1s, one 3 and three 10s, giving 3.