CS2810 OOAIA: Mid-Sem Exam solved

$35.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

Create a class in C++ to represent Students(similar to the previous assignment).
The class should have the following attributes:
● Marks of 5 subjects (No two students will have the same set of scores in all five subjects)
● Skill level(Two students can have the same skill level)
The condition for comparing arbitrary students A and B is:
● Rank(A) < Rank(B) if M1 (A)>M1
(B)
● Rank(A) < Rank(B) if Mi (A)==Mi (B) and Mi+1 (A)>Mi+1
(B) for i=1 to 4 where Mi
(A)
denotes marks of student A in subject i
Rank is defined as the position of a student in the sorted order using the above condition. It is
indexed from 1.
Let the skill levels of student A and student B (A ≠ B) be SA and SB
, and let their ranks be RA and
RB
. (A, B) is a special pair if A’s skill level is higher than B’s skill level, but A has a
greater(worse) rank than B, i.e. (A, B) is a special pair if SA > SB and RA > RB
Count the total number of special pairs.
(Hint: Merge-Sort)
Input Format
The first line contains the total number of students n.
Each of the following n lines contains 6 space-separated integers: marks of 5 subjects and skill
level.
n // Number of total students
n lines in the following format:

Output Format
A single integer denoting the number of special pairs.
Constraints
1 ≤ Number of students ≤ 10
5
1 ≤ Marks in any subject ≤ 10
3
1 ≤ Skill level ≤ 10
9
Subtasks
10 marks:
1 ≤ Number of students ≤ 5000
1 ≤ Marks in any subject ≤ 10
3
1 ≤ Skill level ≤ 10
9
5 marks:
1 ≤ Number of students ≤ 10
5
1 ≤ Marks in any subject ≤ 10
3
1 ≤ Skill level ≤ 10
2
10 marks:
1 ≤ Number of students ≤ 10
5
1 ≤ Marks in any subject ≤ 10
3
1 ≤ Skill level ≤ 10
9
Sample Testcase
Input:
5
1 2 3 4 5 5
2 3 4 5 1 4
3 4 5 1 2 3
4 5 1 2 3 2
5 1 2 3 4 1
Output:
10