GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Sunday, 17 July 2022

[Solution] Largest Family Codechef Solution



A certain parallel universe has exactly N people living in it.

The i-th of these N people claims that they are the parent of exactly Ai of these N people.

However, some of these people might be lying — the i-th person may be either telling the truth (in which case they have exactly Ai children) or lying (in which case they can have any number of children).

It is known that each person has at most one parent. Further, as one would expect, it is not allowed for a person's child to also be their ancestor.

What is the maximum possible number of truth-tellers in

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

this universe?

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.


  • Each test case consists of two lines of input.
    • The first line of each test case contains a single integer N, the number of people.
    • The second line of each test case contains N space-separated integers A1,A2,,AN.

Output Format

For each test case, output on a new line the maximum number of people that can be telling the truth.

Constraints

  • 1T4104

No comments:

Post a Comment