D:Balanced Lineup
总时间限制: 5000ms 内存限制: 65536kB
描述
For the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To keep things simple, he will take a contiguous range of cows from the milking lineup to play the game. However, for all the cows to have fun they should not differ too much in height.
Farmer John has made a list of Q (1 ≤ Q ≤ 200,000) potential groups of cows and their heights (1 ≤ height ≤ 1,000,000). For each group, he wants your help to determine the difference in height between the shortest and the tallest cow in the group.
输入
Line 1: Two space-separated integers, N and Q.
Lines 2..N+1: Line i+1 contains a single integer that is the height of cow i
Lines N+2..N+Q+1: Two integers A and B (1 ≤ A ≤ B ≤ N), representing the range of cows from A to B inclusive.
输出
Lines 1..Q: Each line contains a single integer that is a response to a reply and indicates the difference in height between the tallest and shortest cow in the range.
样例输入
6 3
1
7
3
4
2
5
1 5
4 6
2 2
样例输出
6
3
0
D:Balanced Lineup的更多相关文章
- poj 3264:Balanced Lineup(线段树,经典题)
Balanced Lineup Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 32820 Accepted: 15447 ...
- Balanced Lineup(树状数组 POJ3264)
Balanced Lineup Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 40493 Accepted: 19035 Cas ...
- 三部曲一(数据结构)-1022-Gold Balanced Lineup
Gold Balanced Lineup Time Limit : 4000/2000ms (Java/Other) Memory Limit : 131072/65536K (Java/Othe ...
- poj 3264 Balanced Lineup (RMQ)
/******************************************************* 题目: Balanced Lineup(poj 3264) 链接: http://po ...
- poj3264 - Balanced Lineup(RMQ_ST)
Balanced Lineup Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 45243 Accepted: 21240 ...
- bzoj 1637: [Usaco2007 Mar]Balanced Lineup
1637: [Usaco2007 Mar]Balanced Lineup Time Limit: 5 Sec Memory Limit: 64 MB Description Farmer John ...
- BZOJ-1699 Balanced Lineup 线段树区间最大差值
Balanced Lineup Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 41548 Accepted: 19514 Cas ...
- POJ3264 Balanced Lineup
Balanced Lineup Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 44720 Accepted: 20995 ...
- POJ 3274 Gold Balanced Lineup
Gold Balanced Lineup Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10924 Accepted: 3244 ...
- 哈希-Gold Balanced Lineup 分类: POJ 哈希 2015-08-07 09:04 2人阅读 评论(0) 收藏
Gold Balanced Lineup Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13215 Accepted: 3873 ...
随机推荐
- RDIFramework.NET ━ 9.12 表字段管理 ━ Web部分
RDIFramework.NET ━ .NET快速信息化系统开发框架 9.12 表字段管理 -Web部分 表(字段)综合管理模块主要功能是对数据表本身,表的各个字段做相应的控制,具体有以下功能: ...
- request.get request.GET……
发现他们是不同的. 报错: AttributeError at /add/ 'WSGIRequest' object has no attribute 'get' Request Method: GE ...
- Python 进程
安装Python的paramiko模块 步骤: 1:管理员方式打开cmd,切换到python安装路径的Scripts目录下: 2:执行命令: 1 pip3.5.exe install paramiko ...
- property_自己编写一个读取Property文件的Util类
读取property文件的Util类: 所需jar包: 编写PropertiesUtil类: package com.west.util.property; import java.io.InputS ...
- jQuery的deferred对象详解(转载)
本文转载自: jQuery的deferred对象详解(转载)
- HDU 1258 Sum It Up
Sum It Up Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total S ...
- 在linux中的info手册的用法
就是一些快捷键 空格键向下翻页,当处在当前节点的底部时,空格键跳转到下一个节点. <DEL> 或者 <BACKSPACE> 向上翻页,当处在当前节点的顶部的时候,这两个键可以跳 ...
- VIM技巧之去除代码行号并缩进代码
从网上找源代码时经常会发现代码虽然排版很好,但是前面带着行号,直接复制粘贴得将前面的行号去掉才能编译,而更糟糕的是前面带行号,而代码又没排版,简直是噩梦.在VIM中可以轻易地解决这个问题. 这里将网上 ...
- Android JPush(极光推送)的使用教程
首先进入官网https://www.jpush.cn/,先注册一个账号. 注册号以后,创建应用 1.点击右上角进入个人中心 2.点击创建应用 3.在创建应用界面输入自己项目的应用名和应用的包名,输入后 ...
- 芯航线FPGA学习套件之4*4矩阵键盘模块测试手册
芯航线FPGA学习套件之4*4矩阵键盘模块测试手册 本手册以简明扼要的方式介绍芯航线FPGA学习套件提供的矩阵键盘模块的测试方法: 连接开发板,如下所示: 2.将矩阵键盘模块与开发板按如下图所 ...