ST算法
int n,m,a[maxn],f[maxn][20]; void rmq() { for(int i=1;i<=n;i++)f[i][0]=a[i]; for(int i=1;i<=floor(log(n)/log(2));i++) for(int j=1;j<=n-(1<<i)+1;j++) f[j][i]=max(f[j][i-1],f[j+(1<<(i-1))][i-1]); } int query(int x,int y) { int z=floor(log(y-x+1)/log(2)); return max(f[x][z],f[y-(1<<z)+1][z]); } int main() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); rmq(); return 0; }