FINRAN - EDITORIAL

FINRAN: Editorial

Problem-code: FINRAN

Contest-Code: CSMH2021

Author :GEETHIKA PRIYA

Editorialist: GEETHIKA PRIYA

DIFFICULTY:

Simple

PREREQUISITES:

Basic observations

PROBLEM:

In a classroom, there are n number of students, the students have finished their previous semester and now are stepping into the new semester. One of the faculty who comes to their classroom wants to know about the students who study extremely well as the faculty decides to give extra training to those students and improve them further for good placements. The faculty decides to select the students on the basis of their previous semester marks. He wants only the top rankers of the entire class in the previous semester i.e., notice that there can be more than one student for a particular rank if they score the same marks.
So the faculty wants to find out all the roll numbers of the first ‘k’ ranks(Here k represents the number of ranks that faculty wants to find out). Help the faculty in finding out all the roll numbers of rankers of the class.(The indices of the array are considered as the rollnumbers of the students, consider array indices from 1).

EXPLANATION

Here you were given the number of students and their respective marks as an array, here the indices of the marks are the roll numbers of the students (indices start from 1) and the first ‘k’ ranks and the roll numbers must be printed.
Consider a map having the parameters int and an integer vector, now store the marks of the students in the int and their roll numbers associated with marks in the corresponding vector.
Here use the marks as the key and roll numbers as the values corresponding to them.
Note that we should store the marks in the map in descending order.
Now iterate upto ‘k’ and print the corresponding values in the vector upto the given ‘k’ value and if rank is greater than ‘k’ break the loop.

SOLUTION:

#include 
using namespace std;
int main()
{
	int n,k,x;
	cin>>n;
	map<int,vector,greater> marks;
	for(int i=0;i>x;
		marks[x].push_back(i); 
	}
	cin>>k;
    int c=1;
	    for(auto it=marks.begin();it!=marks.end();it++)
	{
	    cout<<"Rank "<<c<second.begin();y!=it->second.end();y++)
	    {
	     cout<<*y+1<<" ";   
	    }
	    cout<<endl;
	    c++;
	    if(c==k+1)
	    break;
	    
	}
}

Feel free to Share your approach, if you want to. (even if its same :stuck_out_tongue: ) . Suggestions are welcomed as always had been. :slight_smile: