#P5728. 【深基5.例5】旗鼓相当的对手

【深基5.例5】旗鼓相当的对手

Problem Description

There are NN students who took the final exam, and we are given each student’s information: Chinese, Math, and English scores (all natural numbers not exceeding 150150). If for a pair of students i,j\lang i,j\rang, the score difference in each subject is no more than 55, and the difference in total score is no more than 1010, then this pair of students are “evenly matched opponents”. Now, find how many pairs of “evenly matched opponents” there are among these students. The same student may be paired with multiple other students.

Input Format

The first line contains a positive integer NN.

The next NN lines each contain three integers. The ii-th line gives the Chinese, Math, and English scores of the ii-th student. The first student read in is numbered 11.

Output Format

Output one integer, representing the number of pairs of “evenly matched opponents”.

3
90 90 90
85 95 90
80 100 91
2

Hint

Constraints: 2N10002 \le N\le 1000, and each subject score is a natural number not exceeding 150150.

Translated by ChatGPT 5