I have tried solving this question http://www.codechef.com/IOPC2013/problems/IOPC13G , but iam not able to figure out an algorithm, can any one explain/ideas about??
To find the largest possible subset, first find the count of relations of each number.
Now put all the numbers in the set. Then remove those numbers which have less than k relations from the subset and reduce the count of the relations of these numbers still in the subset.
Now some other numbers will have less than k relations due to the reduction. Remove them from the subset and continue this step till either the set is empty or all numbers left have at least k relations.
This is my code.
Check whether you can understanding??
Plz support if you can follow…