Chandler at Joeys place
All submissions for this problem are available.
Chandler visited Joey's house very often. During the month end, Joey noticed there was a hike in his electricity bill. He suspected this was because Chandler was watching "Baywatch" all day. So, he requested the electricity board for issuing a complete day by day receipt and examined the days when Chandler was in his house.
Joey found it difficult to sum up the current used, when Chandler was staying in his house for a continuous number of days. Joey used Chandler's new computer for finding the current used from a day i to day j ( i & j inclusive) given the list of current used for each day.
For Q queries, return the current used from day i to day j.
Newbies, please refer to Codechef sample solution before starting to code,
The first line of input contains an integer N denoting the number of days.
Then a line, containing N space separated integers, denoting the current used A1, A2, ..., AN
This is followed by an integer Q -> number of queries
Followed by Q lines, each containing two integers i and j denoting start and end dates.
Output Q lines, each line containing an integer, the sum of current used from day i to day j.
- 0 ≤ N,Q ≤ 105
- 0 ≤ i ≤ j ≤ 105
- -1015 ≤ Ai ≤ 1015
-2 3 4 9 10
|Time Limit:||0.3 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions