Bear and Medals
Practice
3.9 (52 votes)
Ad Hoc
Approved
Easy
Open
Problem
28% Success 4139 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

View Russian Translation

Limak is a little bear who loves sports. He has been waiting so long for the Day of Sport in his school. But it's today and he is late!

The Day of Sports consists of some number of contests. In each competition there are three medals - one gold, one silver and one bronze. These medals are awarded to three different contestants and there are no ties. You can assume that there are at least three contestants so all three medals are always awarded.

Limak will get to a school in a moment but know he can only cheer for his friends. He has N friends and by a phone they informed him about their achievements so far. Limak knows that i-th of his friends got G[i] golds, S[i] silvers, and B[i] bronzes.

Limak hopes he didn't skip many contests. He knows only numbers of medals awarded to his friends. Help him and with this knowledge find the minimum possible number of contests Limak skipped.

Input format:

The first line contains one integer number T, denoting number of independent test cases. Then T test cases follow.

For each test case the first line contains one integer number N, denoting number of Limak's friends. i-th of the next N lines contains three integers, G[i], S[i], and B[i], denoting numbers of medals awarded to i-th friend.

Output format:

For each test case find the minimum number of contests and print it in the single line.

Constraints:

1 <= T <= 10
1 <= N <= 1000
0 <= G[i], S[i], B[i] <= 1000

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
12 votes
Tags:
ApprovedBasic ProgrammingBrute-force searchEasyOpen
Points:20
30 votes
Tags:
Easy
Points:20
50 votes
Tags:
ApprovedBasic ProgrammingEasyHash MapsOpen