PKU 3368(线段树 + 离散化)
来源:互联网 发布:adobe acrobat 9 mac 编辑:程序博客网 时间:2024/06/06 01:19
Description
You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In addition to that, you are given several queries consisting of indices i and j (1 ≤ i ≤ j ≤ n). For each query, determine the most frequent value among the integers ai , ... , aj.
Input
The input consists of several test cases. Each test case starts with a line containing two integers n and q (1 ≤ n, q ≤ 100000). The next line contains n integers a1 , ... , an (-100000 ≤ ai ≤ 100000, for each i ∈ {1, ..., n}) separated by spaces. You can assume that for each i ∈ {1, ..., n-1}: ai ≤ ai+1. The following q lines contain one query each, consisting of two integers i and j (1 ≤ i ≤ j ≤ n), which indicate the boundary indices for the
query.
The last test case is followed by a line containing a single 0.
Output
For each query, print one line with one integer: The number of occurrences of the most frequent value within the given range.
Sample Input
10 3-1 -1 1 1 1 1 3 10 10 102 31 105 100
Sample Output
143
- PKU 3368(线段树 + 离散化)
- PKU 2528 (线段树 + 离散化)
- PKU 3277(线段树 + 离散化)
- pku 2528 Mayor's posters(线段树+离散化)
- pku 3277 (线段树+离散化)
- pku 3277 City Horizon(离散化+线段树)
- PKU 3327City Horizon离散化+线段树
- pku 2528 Mayor's posters-线段树+离散化
- pku 1151 Atlantis(线段树+离散化+扫描线)
- pku 1177 pictures (线段树+扫描线+离散化)
- HDU 1542 / PKU 1151 (线段树 + 离散化 + 扫描线)
- PKU 2528 Mayor's posters离散的线段树
- 线段树+离散化
- 离散化 + 线段树
- 线段树离散化
- 线段树离散化
- hihoCoder - 1079 - 离散化 (线段树 + 离散化)
- hihoCoder 1079 离散化(线段树离散化)
- 二进制补码的特性
- Zip压缩文件 与 解压 (MFC 文件操作 四 )
- 刚申请的
- C#中抽象类和接口的区别
- Plenty of running backs were faster
- PKU 3368(线段树 + 离散化)
- Cowboys' Spears could miss regular-season opener
- 时钟的显示
- Android对Kernel的改动汇总
- C++ 代码优化
- shell常用规则
- GSM手机绝密技巧
- linux sed
- 奔腾双核与酷睿2双核有何不同?