作业帮 > 综合 > 作业

Give you a number sequence,can you tell me between the i-th

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/10/06 23:54:39
Give you a number sequence,can you tell me between the i-th number and the j-th number,which is the maximum and which is the minimum?
Input
The first line of the input is N and Q.N(N< 2^17) is the number of integers and Q(Q < 2^17) is the number of querys.The second line is the N integers and the following Q lines include two integers i and j(i
区间最值RMQ
ST算法或者线段树
提供一个ST代码
/*
Range Minimum Query
Sparse Table (ST) algorithm
*/
#include
#include
#define min(x,y) (x)(y)?(x):(y)
#define N 100005
int n,s[N],dp[N][25],MAX[N][25],MIN[N][25];
void slove()//psotion
{
int i,j;
for(i=0;i