A city keeps a single registry of every volunteer who has ever signed up with the program, and a separate sign-up log recording which volunteers joined which cleanup drives. A volunteer signs up for a given drive at most once, but the same volunteer may join several different drives. For every drive that has at least one sign-up, the coordinators want to know what percentage of the entire volunteer registry (not just the people who joined any drive at all) that specific drive attracted, so they can see which drives are pulling in the broadest slice of the community.
The first line contains two integers n and m: n is the total number of registered volunteers (numbered 1 to n), and m is the number of sign-up records. Each of the next m lines contains two integers driveId volunteerId, meaning that volunteer volunteerId signed up for drive driveId. Every (driveId, volunteerId) pair is distinct, and every volunteerId is between 1 and n.
For every distinct driveId that appears in the sign-up log, print one line driveId percentage, where percentage equals 100 times (number of volunteers who signed up for that drive) divided by n, printed with exactly two digits after the decimal point. Order the lines by percentage descending; break ties by driveId ascending. If m is 0, print nothing.
Example 1
Input
6 12 1 1 1 2 1 3 1 4 2 1 2 2 3 1 3 2 3 3 3 4 3 5 3 6
Expected
3 100.00 1 66.67 2 33.33
Explanation
There are 6 registered volunteers. Drive 1 has 4 sign-ups (66.67%), drive 2 has 2 sign-ups (33.33%), and drive 3 has all 6 volunteers (100.00%). Sorted by percentage descending, drive 3 comes first, then drive 1, then drive 2.
Example 2
Input
4 6 5 1 5 2 7 1 7 2 9 3 9 4
Expected
5 50.00 7 50.00 9 50.00
Explanation
There are 4 registered volunteers. Drives 5, 7, and 9 each have exactly 2 sign-ups, so each is 50.00%. Since all three percentages tie, they are ordered by ascending driveId: 5, then 7, then 9.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →