403169: GYM101059 D Impressive Queries
Memory Limit:64 MB
Time Limit:10 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
D. Impressive Queriestime limit per test10 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard output
You are given two arrays, A and B, both of size N. You are given Q queries of the form (i, j, k). Where for each query, you have to find the cardinality of the multiset .
InputFirst line contains two integers, N, and Q (1 ≤ N, Q ≤ 105). The next line contains N integers, the array A (1 ≤ Ai ≤ 109). The next line contains N integers, the array B (1 ≤ Bi ≤ 109). Each of the next Q lines contains three integers, i, j and k (1 ≤ i ≤ j ≤ N, 1 ≤ K ≤ 105), which represent a query as defined in the statement.
OutputQ lines, each containing the answer to one query.
ExampleInput5 1Output
1 1 1 1 1
1 1 1 1 1
1 5 1
25