Submit | All submissions | Best solutions | Back to list |
KQUERY - K-query |
English | Vietnamese |
Given a sequence of n numbers a1, a2, ..., an and a number of k- queries. A k-query is a triple (i, j, k) (1 ≤ i ≤ j ≤ n). For each k-query (i, j, k), you have to return the number of elements greater than k in the subsequence ai, ai+1, ..., aj.
Input
- Line 1: n (1 ≤ n ≤ 30000).
- Line 2: n numbers a1, a2 ... an (1 ≤ ai ≤ 109).
- Line 3: q (1 ≤ q ≤ 200000), the number of k- queries.
- In the next q lines, each line contains 3 numbers i, j, k representing a k-query (1 ≤ i ≤ j ≤ n, 1 ≤ k ≤ 109).
Output
- For each k-query (i, j, k), print the number of elements greater than k in the subsequence ai, ai+1 ... aj in a single line.
Example
Input 5 5 1 2 3 4 3 2 4 1 4 4 4 1 5 2 Output 2 0 3
Added by: | Jimmy |
Date: | 2008-10-26 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ERL JS-RHINO NODEJS PERL6 VB.NET |
Resource: | Gomoku |
hide comments
|
||||||
2024-08-04 16:24:58
segment tree + upper bound |
||||||
2023-12-20 14:14:48
similar problem https://codeforces.com/contest/813/problem/E Last edit: 2023-12-20 14:15:10 |
||||||
2023-08-04 14:29:40
Merge Sort Tree Classic |
||||||
2023-07-16 23:46:00
Use MO + BIT, or just MO with sqrt |
||||||
2023-07-09 11:42:00
I am getting TLE for Merge Sort Tree + Upper Bound Solution Can someone help please This is my implementation <snip> [Simes]: This is not the place for a code review, use the forum Last edit: 2023-07-09 19:30:24 |
||||||
2023-05-06 14:10:19
segment tree using merge sort + upper_bound |
||||||
2023-04-09 18:29:12
segment tree+ binary search |
||||||
2022-09-17 13:08:53
Uber OA Problem |
||||||
2022-08-31 11:25:49
nice and easy problem.... merge sort tree + binary search. and boom ;) |
||||||
2022-06-10 04:39:39
offline segment tree |