Sequence and Queries 9
Time limit6sMemory limit512 MB
For each query range [i,j] and value k, count ordered pairs (p,q) from that range with A[p]*B[q] <= k.
- Level
Hard9 of 10
- Topics
- Divide and conquer, Segment tree, Sorting, Dynamic programming
- Solved
- No attempts yet
Problem
Two sequences of length are given: and . Write a program that processes the following query.
i j k: print the number of pairs such that , , and .
The indices and are chosen independently, so a pair with also counts.
Input
The first line contains the size of the sequences, ().
The second line contains . ()
The third line contains . ()
The fourth line contains the number of queries, ().
Each of the next lines contains one query , , . (, )
Output
For each query, print the answer on its own line, in the order the queries are given.