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 qu
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/28 05:41:55
![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 qu](/uploads/image/z/13939370-26-0.jpg?t=Give+you+a+number+sequence%2Ccan+you+tell+me+between+the+i-th+number+and+the+j-th+number%2Cwhich+is+the+maximum+and+which+is+the+minimum%3FInput+The+first+line+of+the+input+is+N+and+Q.N%28N%3C+2%5E17%29+is+the+number+of+integers+and+Q%28Q+%3C+2%5E17%29+is+the+number+of+qu)
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 qu
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
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 qu
区间最值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