#K60297. Maximum Valid Social Media Participations

    ID: 31055 Type: Default 1000ms 256MiB

Maximum Valid Social Media Participations

Maximum Valid Social Media Participations

Given a series of user activities in a social media event, determine the maximum number of valid participations across multiple test cases. In this event, each user may only participate on days that are not consecutive to their previous valid participation. For each user, the first participation is always considered valid. Any subsequent participation is valid only if it does not occur on the day immediately following the previous valid participation.

For example, if a user participates on days 1, 3, and 4, then the participations on days 1 and 3 are valid, while the participation on day 4 is invalid if day 3 was already counted as valid. Compute the total number of valid participations for each test case and output the results.

inputFormat

The first line of input contains an integer T, the number of test cases. Each test case starts with an integer N, the number of activities. This is followed by N pairs of integers, where each pair consists of a userID and the day number on which the user participated. All input is provided via standard input (stdin).

outputFormat

For each test case, output a single integer on a new line representing the maximum total number of valid participations as defined by the rule that a user cannot participate on consecutive days (after a valid participation). All output should be written to standard output (stdout).## sample

2
5 1 1 2 2 1 3 3 4 2 5
4 1 1 2 1 3 2 1 2
5

3

</p>