ACM: 线段树 poj 3264
来源:互联网 发布:java回退流 编辑:程序博客网 时间:2024/05/17 04:10
For the daily milking, Farmer John's N cows (1 ≤ N≤ 50,000) always line up in the same order. One day Farmer Johndecides to organize a game of Ultimate Frisbee with some of thecows. To keep things simple, he will take a contiguous range ofcows from the milking lineup to play the game. However, for all thecows 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 thedifference in height between the shortest and the tallest cow inthe group.
Input
Lines 2..N+1: Line i+1 contains a single integer thatis the height of cow i
Lines N+2..N+Q+1: Two integers A andB (1 ≤ A ≤ B ≤ N), representing therange of cows from A to B inclusive.
Output
Sample Input
6 3
1
7
3
4
2
5
1 5
4 6
2 2
Sample Output
6
3
0
题意: 求区间内最大最小值得差.
解题思路:
代码:
#include<cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 200005
struct node
{
}pt[MAX*2];
int n, m;
int a;
int A, B;
inline int min(int a, int b)
{
}
inline int max(int a, int b)
{
}
void buildTree(int l, int r, int pos)
{
}
void insert(int l, int r, int val, int pos)
{
}
int findMax(int l, int r, int pos)
{
}
int findMin(int l, int r, int pos)
{
}
int main()
{
//
}
- ACM: 线段树 poj 3264
- ACM: 线段树 poj 2352
- ACM: 线段树 poj 1177
- ACM: 线段树 poj 3468
- ACM: 线段树 poj 3277
- ACM: 线段树 poj 3368
- ACM: 线段树 poj 2528 离散化即可
- ACM: 线段树 poj 1151 足足想了三…
- ACM: 线段树 poj 2828 认真对待每…
- ACM: 线段树 poj 2777 继续熟练线…
- ACM: 线段树 poj 2886 约瑟夫问题
- ACM: 线段树 poj 2750 连续最大和
- ACM: 线段树 poj 2482 煽情的情书!…
- poj 3264 Balanced Lineup(线段树)
- poj 3321 Apple Tree 线段树
- poj 2182 Lost Cows 线段树
- 【线段树】 POJ 2828 Buy Tickets
- POj 2379 ACM Rank Table
- C++ 友元类
- ACM: 树状数组 poj 1195
- ACM: 树状数组 poj 2155 学习《浅…
- ACM: 树状数组 poj 3321 图论+树状…
- spring配置出错at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244
- ACM: 线段树 poj 3264
- ACM: 线段树 poj 3368
- ACM: 并查集 poj 1703
- 凌宇的项目之旅-关于自定义锁屏
- 兴趣学习: 信息熵 ---- 《数学…
- ACM: 并查集 poj 2492
- ACM: 《黑书》高性能计算机
- ACM: 动态规划题 poj 1054
- ACM: 动态规划题 poj3280