아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Team ranking

시간 제한1초메모리 제한1024 MB

요약
각 선수의 성별, 기록 거리와 시간, 소속 팀이 주어질 때 팀 등급을 정하고, 조건에 맞는 상위 세 명의 기록 합으로 팀 순위를 매긴다.
난이도

보통10점 중 4점

유형
정렬, 구현, 그리디
정답자
아직 제출이 없습니다

문제

At ultrarunning competitions participants must cover as long of a distance as they can within a certain time. Ranking will be determined by the distance covered; if this is equal, the faster competitor wins. In individual competitions there are two classes: men (M) and women (N).

Additionally there is a team ranking. Every competitor can belong to at most one team. Teams are divided into three classes: men (M), women (N) and mixed teams (S). Team that has competitors of both genders in it is a mixed team; team class is determined based on all of its members. Team result is determined by the sum of the results of the three best members that satisfy the conditions for the team class (this means that the result of a mixed team must be based on results of either two men and one woman or two women and one man).

Write a program that finds team results based on individual results.

입력

The first line of input contains one integer: number of participants NN. On each of the next NN lines there are attributes of one competitor: name, class, distance covered, time, team name (missing if the competitor does not belong to a team). All names contain only capital Latin letters and spaces. Amount of data and values of attributes are realistic.

출력

Write the team results into output in ranked order starting from the best, one line per team: place in overall ranking, class and place within class, team name, distance, time. If team does not have three results, output DQ, class, team name. Teams with equal results should be ordered in lexicographic ordering of the names, as a place output the place (or place within class) of the first team. Disqualified (DQ) teams should be listed last.

예제1

  1. 예제 1

    입력
    11
    TOOMAS HUNT,M,211.0KM,24:09:10,METSARAHVAS
    MARTIN PODER,M,211.0KM,27:07:45,METSARAHVAS
    PEETER KARU,M,DQ,,METSARAHVAS
    PILLE KASK,N,178.0KM,30:21:19,TAIMED JA LIBLIKAD
    GETTER MATAS,N,162.0KM,27:40:30,TAIMED JA LIBLIKAD
    MARI PURAVIK,N,42.2KM,4:30:10
    JANA PILVEMAGI,N,112.4KM,18:40:11,TAIMED JA LIBLIKAD
    TONIS ROHT,M,199.0KM,30:34:10,TAIMED JA LIBLIKAD
    JAAK MAASIKAS,M,208.0KM,28:23:14,PIKK JA ROHELINE
    JAAN MAASIKAS,M,203.0KM,27:27:43,PIKK JA ROHELINE
    JAAGUP MAASIKAS,M,201.0KM,29:13:34,PIKK JA ROHELINE
    
    예상 출력
    1,M1,PIKK JA ROHELINE,612.0KM,85:04:31
    2,S1,TAIMED JA LIBLIKAD,539.0KM,88:35:59
    DQ,M,METSARAHVAS