E - Frequent values

这是一个关于处理序列查询的问题,输入包含多个测试用例,每个用例包含一个非递减顺序的整数序列和一系列查询。对于每个查询,需要找出在给定范围内的整数中最常出现的值。输出为每个查询中指定区间内最频繁出现的数值的出现次数。

Time Limit: 2000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u

[Submit]   [Go Back]   [Status]

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 10
2 3
1 10
5 10
0

Sample Output

1
4
3
液晶显示器去保护LCD常用PWM芯片去除保护方法大全 芯片型号 供电脚 使能 输出脚 CT/RT 反馈脚 保护脚 去保护方法 用途 AAT1100 3 无 4//5/6 12 1/15/14 8 飞线到地 液晶屏板 AAT1100A 3 16 4//5/6 无 1/15/14 8 飞线到地 液晶屏板 AAT1100B 3 16 4//5/6 10 1/15/14 8 飞线到地 液晶屏板 AAT1100C 3 16 4//5/6 无 1/15/14 8 飞线到地 液晶屏板 AAT1107 9 无 2007/10/14 1月2日 2004/3/13 15 飞线到地 液晶屏板 AAT1164或68 22 30 1/13/14/28/32 丁一网 25/23/27 www.Haojdwx.com 液晶屏板 AA1343 9 无 7月10日 1月2日 4_3/12_13 15 飞线到地 液晶屏板 AT1380 3 无 5 7 1 2 飞线到地 液晶屏板 AT1741 9 无 7月10日 1月2日 3/4/13/14 15 飞线到地 高压板 BA9741 9 无 7月10日 1月2日 3/4/13/14 15 飞线到地 高压板 BA9743 9 无 7月10日 1月2日 3/4/13/14 15 飞线到地 液晶屏板 BIT3101A 10 6 8月9日 1 4月13日 2月15日 吸空断开 高压板 BIT3102A 2 无 1 7 4 5 吸空断开 高压板 BIT3105 13/18 14 9/10/11/12 7 1 4 吸空断开 高压板 BIT3106 6月12日 24 15/16/17/18 9 2月29日 4月27日 吸空断开 高压板 BIT3107 13/18 14 9/10/11/12 7 1 4 吸空断开 高压板 BIT3107/3713 10 6 8月9日 4 1 5月1日 3-2个IN4148到地 高压板 DF6106 2 7月8日 1月16日 4 14 飞线到地? 高压板 DF6109 2 8 1/3/14/16 5 15 飞线到地? 高压板 FAN7314 17 3 18/19/14/15 12月13日 9 1 1个IN4148到地 高压板 FP5451 9 无 7/10/ 1月2日 3/4/13/14 15 飞线到地 高压板 KA7500 12 无 8/9/10/11选2 5月6日 1/2/15/16 1月16日 飞线到地 高压板 MB3775 9 无 7月10日 1月2日 3/4/13/14 15 飞线到地 高压板 OB3318 7 1 8月9日 12 3月6日 Haojdwx.com 高压板 OZ960 5 3 11/12/19/20 18/17 9 10/2空 3个IN14148到地 高压板 OZ962 16 12 10月11日 14/15 6 4月2日 Haojdwx.com 高压板 OZ964 5 3 11/12/19/20 18/17 9 1 3个IN14148到地 高压板 OZ965 16 12 10月11日 14/15 6 4 飞线到地 高压板 OZ9RR 6 1 4月5日 2 8 7 拆外接高压电容 高压板 OZ9910 13 8 1/3/15/16 5 11 10 3个IN14148到地 高压板 OZ9930 6 1 4月5日 2 8 7 拆外接高压电容 高压板 OZ9936 6 1 4月5日 2 8 7 拆外接高压电容 高压板 OZ937 4脚是电流检测,9脚是电压检测,取消保护只需要把14脚直接接地 OZ9938 2 10 1月15日 13 5 3/6空 短接到地/吸空 高压板 OZ9939 2 10 1月15日 13 5 3/6空 短接到地/吸空 高压板 SEM2005 10 11 8月9日 12 4 3月2日 吸空断开 高压板 SP5001 13/18 14 9/10/11/12 7 1 4 吸空断开 高压板 TL5001 2 无 1 7 4 5 飞线到地 高压板 TL1451 9 无 7月10日 1月2日 3/4/13/14 15 飞线到地 高压板 TL1454 9 无 7月10日 1月2日 3/4/13/14 15 飞线到地 高压板 TL494 12 无 8/9/10/11选2 5月6日 1/2/15/16 1月16日 飞线到地 高压板 好家电网——更多图纸、总线数据资料,免注册、免登陆可下载 www.Haojdwx.com
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值