All Tracks Problem

Make Groups



Fredo is a class teacher. Today, he wants his class to form groups for an activity. He noticed that some students are absent. The number of present students in the class is a multiple of 3. So, he asked the students to form a group of 3 students for the activity.
He knows that students will form groups as:
First three rank holders present in the class would make one group, next three would make other group and so on.

He wants to make an entry of all the groups formed. So, he wants you to maintain a table which stores the minimum and maximum ranked student's roll number for each group. He wants the groups to be ordered in the table such that the group with minimum ranked students comes first , then the next group with ranks greater than the previous group and less than rest groups , and so on.
See the sample input and output for clarity.

Input Format:

Table : Students

Field Type
RollNo INT
Rank INT

Sample Input:

Sample Students Table:

RollNo Rank
2013023 13
2013045 23
2013001 45
2013005 1
2013040 3
2013044 14

Sample Output:

first last
2013005 2013023
2013044 2013001

The groups formed are:

The group with member 2013005 has all ranks less than group with member 2013044, so that group comes first in the table.

Time Limit: 5 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: MySQL, PostgreSQL, MSSQL, Oracle Database


Initializing Code Editor...
Your Rating:


View All Notifications