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
hide comments
revpro:
2019-03-19 10:14:47
can somebody provide edge cases I'm getting WA on 9th.
|
|
letuantam96:
2019-03-18 18:25:33
I got O(n) complexity and somehow i still got LTE. Guess i cant use normal DP =)) |
|
ab_biswas09:
2019-03-15 22:17:02
AC in One GO |
|
shawnliang:
2019-03-12 02:09:35
AC in 0.09s with c++ ios_base::sync_with_stdio(false) and std::cin.tie(NULL) and cout.flush().
|
|
trishala_naman:
2019-02-21 01:07:01
Try i/p:
|
|
sajalagrawal14:
2019-02-13 08:46:48
very strict time limit . also for c++ users dont use only '/n' it can cause ans wrong , instead use endl Last edit: 2019-02-13 08:47:07 |
|
akj698:
2019-02-09 08:32:16
A must do problem :) |
|
ada107:
2019-02-02 14:53:31
TLE after 8th test-case in Java, used fast i/o. Any other way to resolve it? Last edit: 2019-02-02 14:54:25 |
|
wounded_wolf:
2019-01-16 14:12:30
Please help for java, getting tle! |
|
sawlani_123:
2019-01-08 07:09:29
Nice question on segment tree .Learnt a Lot! |
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 |