b树范围查找
The following question/problem is asked on http://www.spoj.com/problems/GSS1/
在http://www.spoj.com/problems/GSS1/上询问以下问题/问题
Problem:
问题:
A sequence is given: A[1], A[2], ..., A[N] .( |A[i]| ≤ 15007 , 1 ≤ N ≤ 50000 ). Query defined as follows:
给出了一个序列: A [1],A [2],...,A [N] 。 (| A [i] |≤15007,1≤N≤50000) 。 查询定义如下:
Query(x,y) = Max { a[i]+a[i+1]+...+a[j] ; x ≤ i ≤ j ≤ y }.
Query(x,y)= Max {a [i] + a [i + 1] + ... + a [j]; x≤i≤j≤y}。
Given M queries, your program must output the results of the queries.
给定M个查询,您的程序必须输出查询结果。
Input
输入项
First line will have input N
第一行将输入N
Second line will have N numbers of the sequence
第二行将有N个序列
Third line will input M
第三行将输入M
Fourth line will have those M queries of two numbers
第四行将有两个数字的M个查询
Output</