| # | User | Rating |
|---|---|---|
| 1 | jiangly | 3810 |
| 2 | Benq | 3676 |
| 3 | Kevin114514 | 3655 |
| 4 | maroonrk | 3463 |
| 5 | strapple | 3390 |
| 6 | Um_nik | 3387 |
| 7 | tourist | 3384 |
| 8 | heuristica | 3322 |
| 9 | turmax | 3319 |
| 10 | jiangbowen | 3291 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 155 |
| 2 | nik_exists | 150 |
| 2 | maspy | 150 |
| 4 | Um_nik | 144 |
| 5 | Errichto | 139 |
| 6 | adamant | 137 |
| 6 | AmShZ | 137 |
| 8 | BledDest | 132 |
| 8 | maroonrk | 132 |
| 10 | qwexd | 129 |
|
+3
Before going into the solution, consider this: For every query, count the number of element which are less than or equal to k,let us call it X. our answer for every query will be j-i+1-X Now, to calculate the value of X:- - Declare an array A of size n. Initially all values zero. - Store the indexes of all the integers in a 2-D vector V. There can be at most n distinct integers. - Store all the queries in a vector and sort it according to k(ascending order). - Now iterate over query vector and for every number less than or equal to k, update the array for all the indexes stored in V for corresponding number. - Count the sum of elements in array A from i to j. X=sum(l,r) by Range sum query using segment tree or BIT. - Answer to each query=**j-i+1-X** |
| Name |
|---|


