All Tracks Basic Programming Input/Output Basics of Input/Output Problem

Play with numbers
Tag(s):
No tags
Problem
Editorial
Analytics

You are given an array of n numbers and q queries. For each query you have to print the floor of the expected value(mean) of the subarray from L to R.

\(Input :\)

First line contains two integers N and Q denoting number of array elements and number of queries.

Next line contains N space seperated integers denoting array elements.

Next Q lines contain two integers L and R(indices of the array).

\(Output :\)

print a single integer denoting the answer.

\(Constraints\) :

1<= N ,Q,L,R <= 10^6

1<= Array elements <= 10^9

NOTE

Use Fast I/O

Problem setter : Sheldon Tauro

SAMPLE INPUT
5 3
1 2 3 4 5
1 3
2 4
2 5
SAMPLE OUTPUT
2 
3
3
Time Limit: 1.5 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, C++17, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, Java 14, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, Python 3.8, R(RScript), Racket, Ruby, Rust, Scala, Swift-4.1, Swift, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

IIIT Allahabad

Challenge Name

Codemania 2.0

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?