#K11841. Count Likes in a Time Window

    ID: 23558 Type: Default 1000ms 256MiB

Count Likes in a Time Window

Count Likes in a Time Window

You are given information about several posts and a series of queries. Each post has an identifier, a timestamp, a declared number of like events (L), and a series of timestamps when the likes were registered. For each query, given three integers A, B, and T, your task is to count how many posts received at least T likes in the time window [A, B].

In mathematical terms, for a given query, count the number of posts for which [ \text{#likes in } [A,B] \ge T ]

You must read the input from standard input (stdin) and write your output to standard output (stdout).

inputFormat

The first line contains two integers N and Q, where N is the number of posts and Q is the number of queries.

This is followed by N lines, each describing a post. Each post’s description starts with three integers: P (post ID), Tp (a timestamp value, not used in computation), and L (the number of like events). This is followed by L integers representing the timestamps at which likes were given.

Then Q lines follow, each containing three integers A, B, and T describing a query. Here, the time window is [A, B] and you need to count posts with at least T likes in this window.

outputFormat

For each query, output a single integer on a new line representing the count of posts that received at least T likes within the time window [A, B].## sample

3 2
101 1 5 2 4 6 8 10
102 2 4 3 5 7
103 3 3 4 6 8
2 8 2
1 10 5
3

1

</p>