Given an array of **n** integers and **q** queries. Write a program to print floor value of mean in range **l** to **r **for each query in a new line.

Examples: Input : arr[] = {1, 2, 3, 4, 5} q = 3 0 2 1 3 0 4 Output : 2 3 3 Here for 0 to 2 (1 + 2 + 3) / 3 = 2 Input : arr[] = {6, 7, 8, 10} q = 2 0 3 1 2 Output : 7 7

**Input:**

The first line consists of an integer **T** i.e number of test cases. The first line of each test case consists of two integer **n** and **q**.The next line consists of **n **spaced integers. The next line consists of **2*q** spaced integers each pair representing the range.

**Output:**

Print the mean(floor value) in given range for each query in new line.

**Constraints:**

1<=T<=100

1<=q 1<=a[i]<=1000

**Example:
Input:**

1

5 3

1 2 3 4 5

0 2 1 3 0 4

**Output:**

2 3 3

Author: saksham0751

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

saiujwal13083 | 347 |

isiddhisingh | 252 |

Abhishek_Jadhav | 243 |

_uncle_sam_ | 221 |

c_ocoooo | 217 |

saiujwal13083 | 610 |

SumitSingh27 | 466 |

c_ocoooo | 456 |

rathiarpit29 | 379 |

NaveenKumarNakka | 370 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4931 |

Quandray | 4598 |

Login to report an issue on this page.