#K55082. Post with Maximum Unique Likes

    ID: 29896 Type: Default 1000ms 256MiB

Post with Maximum Unique Likes

Post with Maximum Unique Likes

You are given a list of like events on various posts and a set of queries. Each like event is represented as a triple (user_id, post_id, timestamp). For each query defined by a time interval \([L, R]\), determine the post that has received the highest number of unique user likes within that interval. In case of a tie, choose the post with the smallest post_id.

If no like events occur in the given time interval, output None for that query.

Note: A like event is only considered if its timestamp \(t\) satisfies \(L \le t \le R\). The number of unique users is counted per post based on these filtered events.

inputFormat

The input is read from stdin and has the following format:

  1. An integer n denoting the number of like events.
  2. n subsequent lines, each containing three integers: user_id, post_id, and timestamp separated by spaces.
  3. An integer q denoting the number of queries.
  4. q subsequent lines, each containing two integers: start_time and end_time separated by a space.

outputFormat

For each query, output the post_id that has the maximum number of unique user likes in the given time interval. If no likes occur in that interval, output None. Each result should be printed on a separate line to stdout.

## sample
2
1 100 10
2 100 15
1
5 20
100

</p>