• [1118] Marisa's Affair

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Everyone knows that Kirisame Marisa(きりさめ·まりさ) often has affaires with other witches in TouHou.
    For example, she has an affair with Reimu today and tomorrow is Flandre.
    You have to make clear that how many witches she has affairs with.

  • 输入
  • This problem has several cases.
    The first line of each case contains an integer N(0 < N <= 5000).
    Then follows N lines. The ith has a name NAMEi and an integer Hi(0 < Hi < 20000), means at the ith day Marisa has an affair with NAMEi, and NAMEi increases Hi likability.
    You can consider that every name only contains uppercase and lowercase letters, and not longer then 20;
  • 输出
  • For each case, you should output like that:
    At the first line, you should output how many witches Marisa has affaires with;
    Then each line output like that:
    The name of the witch, the likability with that witch and the time(s) they have affaires. Order by likability descending.
    If their likabilities are the same, then order by affair times descending.
    If their likabilities and affair times are the same, then order by lexicographical order increasing.
  • 样例输入
  • 3
    Flandre 3
    Reimu 10
    Flandre 5
    
  • 样例输出
  • 2
    Reimu 10 1
    Flandre 8 2
    
  • 提示
  • 来源
  • XadillaX
  • 操作

显示春菜