PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000072. Mode trên đoạn tĩnh (Static Range Mode Query)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Mode trên đoạn tĩnh (Static Range Mode Query)
Static Range Mode Query
Source: Library Checker
Version: Phuoc Hung OJ Extended
Problem Statement
For each half-open range of the zero-indexed array, output any mode value and its frequency. If several values share the maximum frequency, any one is valid.
Input
Read , the array, and half-open ranges using zero-based indices.
Output
Print mode_value frequency on one line for each query.
Subtasks
- Subtask 1 (10 points): , . ; ; .
- Subtask 2 (20 points): , . ; ; .
- Subtask 3 (30 points): , . ; ; .
- Subtask 4 (40 points): , . ; ; .
Examples
Input
5 3
3 7 1 2 1
1 5
3 4
0 4
Output
1 2
2 1
3 1
Explanation
Range has values : mode 1 appears twice. Range contains only 2. In every value occurs once, so 3 1 and any other present value paired with 1 are all valid.