Submit | All submissions | Best solutions | Back to list |
GSS1 - Can you answer these queries I |
You are given a sequence A[1], A[2] ... A[N] . ( |A[i]| ≤ 15007 , 1 ≤ N ≤ 50000 ). A query is defined as follows:
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 these queries.
Input
- The first line of the input file contains the integer N.
- In the second line, N numbers follow.
- The third line contains the integer M.
- M lines follow, where line i contains 2 numbers xi and yi.
Output
Your program should output the results of the M queries, one query per line.
Example
Input: 3 -1 2 3 1 1 2 Output: 2
Added by: | Nguyen Dinh Tu |
Date: | 2006-11-01 |
Time limit: | 1s |
Source limit: | 5000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ERL JS-RHINO NODEJS PERL6 VB.NET |
hide comments
|
||||||||||||||
2024-12-02 05:23:42
I try to solve it using Sqrt_Decomp or MO but wa in test 9 Solved it using Segment Last edit: 2024-12-02 05:45:33 |
||||||||||||||
2024-11-14 21:54:38
I can't answer your queries man. |
||||||||||||||
2023-11-02 20:48:21
WA on case 9???? |
||||||||||||||
2023-08-28 09:31:14
need a sherlock brain for the testcase where my code get failed |
||||||||||||||
2023-06-12 15:24:39
i learnt a lot form this question.this question was equal to 5 seg t questions. |
||||||||||||||
2023-03-02 15:25:40
is it can be solved by segment tree(maximum subarray sum) |
||||||||||||||
2023-01-26 08:12:16
You should avoid printing answer for empty subarray (i.e 0) , They are asking for a subbarray with atleast one element Last edit: 2023-01-26 08:12:35 |
||||||||||||||
2022-11-11 14:01:50
OMG.Quite Difficult:( |
||||||||||||||
2022-09-22 09:25:59
Why wrong answer on test #9? Did I missed something? |
||||||||||||||
2022-08-30 14:06:37
Why? |