Question Name:Rank List

``````#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
int n; cin >> n;

vector<pair<int, pair<string, int>>> v;

for(int i = 0; i < n; i++)
{
string s; int p1, p2;
cin >> s >> p1 >> p2;

v.push_back(make_pair(-p2, make_pair(s, p1)));
}

sort(v.begin(), v.end());

for(int i = 0; i < n; i++)
{
cout << v[i].second.first << " " << v[i].second.second << " " << -v[i].first << endl;
}
}``````
• Problem Description
Mid semester marks of a particular subject is announced , since you are curious in knowing your position in class so you decided to make a rank list . You are given the name , scholar number and marks of every student in your class.

You have to come up with accurate rank list i.e student having maximum marks at the top and if two students are having same marks then the student having lexicographically smaller name comes first , if both name and marks of the student collide then student having smaller scholar number comes first.

Input:
First line of input contains N – Total number of students in class
Next N line contains name of student , scholar number and marks scored in exam .

Output:
Print the ranklist of students as explained above.

Constraints
1 <= N <= 1000
1 <= length of name <= 10
1 <= scholar number <= 1000
0 <= marks <= 30
• Test Case 1
Input (stdin)2
bilal 8 28
sai 2 8
Expected Outputbilal 8 28
sai 2 8
• Test Case 2
Input (stdin)5
arun 8 28
harshit 10 30
surya 7 26
satyam 27 6
arun 1 28
Expected Outputharshit 10 30
arun 1 28
arun 8 28
surya 7 26
satyam 27 6