SOLVE

LATER

Micro and Courses

Problem

Editorial

Analytics

Micro's school puts a limit on the maximum number of students that can be enrolled in any course. As the new session is starting all the students have filled their preferences. Now since Micro is very busy, he needs your help. He'll give you details about the courses, their limits and about all the students and their rank in the previous session and about their preferences. Course allotment is done on the basis of student's preference, their respective rank and the limit of the course. Check sample for more clarity. Now help Micro generate the list of course allotment. For better understanding of the problem, refer to the sample explanation given below.

These are three tables that you have to use. The schema of the tables is as given below.

Table : **Students**

Field | Type |
---|---|

Student_ID | int |

Rank | int |

Table: **Courses**

Field | Type |
---|---|

Course_ID | int |

CName | text |

CLimit | int |

Table: **Preferences**

Field | Type |
---|---|

Student_ID | int |

Course_ID | int |

Student_ID |
---|

1 |

2 |

**Sample Students table:**

Student_ID | Rank |
---|---|

1 | 3 |

2 | 1 |

3 | 4 |

4 | 2 |

**Sample Courses table:**

Course_ID | CName | CLimit |
---|---|---|

101 | Science | 2 |

102 | Math | 3 |

**Sample Preferences table:**

Student_ID | Course_ID |
---|---|

1 | 101 |

2 | 101 |

3 | 101 |

1 | 102 |

4 | 101 |

**Output:**

Student_ID | Course_ID |
---|---|

1 | 102 |

2 | 101 |

4 | 101 |

Explanation

$$4$$ students added $$Science$$ as preference but it's limit is $$2$$, so the first $$2$$ students (according to rank), will get the course.

Only $$1$$ student preferred $$Math$$, and it's limit is $$3$$, so he'll get it.

Time Limit:
1 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_Db

Initializing Code Editor...

{"d99f7d0": "/pagelets/problem-author-tester/sql/micro-and-courses/", "6ec341b": "/pagelets/show-submission/sql/micro-and-courses/", "39f3372": "/pagelets/recommended-problems/sql/micro-and-courses/", "753538d": "/pagelets/problems-hint/sql/micro-and-courses/", "8500fba": "/pagelets/suggested-problems/sql/micro-and-courses/"}

realtime.hackerearth.com

80

1fe8d6cdbcc301acfccaa2f1fd5326ea641bf0a3

58a29e5cae2309f04b28

/realtime/pusher/auth/