#C14777. Filter People by Age

    ID: 44463 Type: Default 1000ms 256MiB

Filter People by Age

Filter People by Age

You are given a list of people records and an age threshold. Each record contains three fields: name (a string), age (an integer) and city (a string). Your task is to filter out those records where the age is strictly greater than the given threshold and output a JSON array of objects. Each object in the output should contain only the name and age of the person.

Note: The comparison is strict; that is, a person will be included in the output only if age > age_threshold.

Input/Output: The input is read from standard input and the output is printed to standard output.

Input Format:

  • The first line contains an integer N, the number of people records.
  • The next N lines each contain three space-separated values: name, age and city. (Note: The name and city will not contain spaces.)
  • The last line contains an integer representing the age threshold.

Output Format:

  • Output a single line containing a JSON array. Each element in the array should be a JSON object with two keys: name and age. The order of the records should be the same as in the input.

Example:

Input:
3
Alice 30 NewYork
Bob 25 LosAngeles
Charlie 35 Chicago
28

Output: [{"name":"Alice","age":30},{"name":"Charlie","age":35}]

</p>

inputFormat

The input is read from standard input (stdin) with the following format:

  • The first line contains a single integer N denoting the number of people.
  • The next N lines each contain a person's information in the format: name age city, separated by spaces.
  • The last line contains an integer representing the age threshold.

Note: The name and city values are guaranteed to not contain spaces.

outputFormat

The output should be printed to standard output (stdout) as a single JSON array (in one line). Each element in the array is a JSON object with two keys: name and age, including only those people whose age is strictly greater than the provided threshold.

## sample
3
Alice 30 NewYork
Bob 25 LosAngeles
Charlie 35 Chicago
20
[{"name":"Alice","age":30},{"name":"Bob","age":25},{"name":"Charlie","age":35}]