#P1786. Gang Position Adjustment

    ID: 15071 Type: Default 1000ms 256MiB

Gang Position Adjustment

Gang Position Adjustment

In a gang there is at most one Boss, two Vice Leaders, two Protectors, four Elders, seven Hall Masters, twenty‐five Elites, and an unlimited number of Members. absi2011 intends to adjust almost everyone’s position except for the Boss and Vice Leaders (which must remain unchanged).

You are given each member’s information: name (a string of at most 30 characters), original position, gang contribution, and level. For members whose positions can be adjusted (i.e. those not originally Boss or Vice Leader), you must reassign their positions according to their gang contribution ranking. The member with the highest gang contribution among those eligible will get the highest available position, as follows:

  • The top 2 receive the Protector position.
  • The next 4 receive the Elder position.
  • The next 7 receive the HallMaster position.
  • The next 25 receive the Elite position.
  • Any remaining members become Members.

After reassigning positions, the final display list (as shown in the game) must be sorted first by position priority and then by level (in descending order). The position priority order is:

$$Boss \prec ViceLeader \prec Protector \prec Elder \prec HallMaster \prec Elite \prec Member $$

For members in the same position with equal levels, maintain their original input order.

inputFormat

The first line contains an integer n, the number of members. Each of the next n lines contains four items separated by spaces:

  • name: a string (length ≤ 30)
  • original position: one of Boss, ViceLeader, Protector, Elder, HallMaster, Elite, or Member
  • gang contribution: an integer
  • level: an integer

outputFormat

Output the adjusted list with one member per line. Each line should include the member's name, new position, and level (separated by a space), sorted by:

  • Primary key: position with the priority order: Boss < ViceLeader < Protector < Elder < HallMaster < Elite < Member.
  • Secondary key: level in descending order.
  • If levels are equal, preserve the original input order.

sample

6
John Boss 500 100
Doe ViceLeader 400 90
Alice Elite 300 80
Bob Member 350 85
Charlie Elder 320 82
Dave HallMaster 310 75
John Boss 100

Doe ViceLeader 90 Bob Protector 85 Charlie Protector 82 Alice Elder 80 Dave Elder 75

</p>