方針

かなり複雑なシミュレーション問題。

与えられたデータを加工するところで挫折した.

時間をかければ解けたかもしれない問題だった.

解答

class ContestScoreboard:
    def findWinner(self, scores):
        n = len(scores)
        names = ["0"] * n
        could = [0] * n
        results = [False] * n

        submittimes = set([])
        for i in range(n):
            st = scores[i].split()
            names[i] = st[0]
            results[i] = []
            for j in range(1, len(st)):
                st2 = st[j].split("/")
                time = int(st2[1])
                submittimes.add(time)

                score = int(st2[0])
                results[i].  append((time, score))
        could[names.index(min(names))] = 1
        sts = sorted(list(submittimes))

        simscores = [0] * n

        for tm in sts:
            simscores = [0] * n
            maxscore = 0
            maxteam = -1

            for i in range(n):
                scr = 0
                for (ttt, sss) in results[i]:
                    if ttt <= tm:
                        scr += sss
                simscores[i] = scr

                if maxscore < scr:
                    maxscore = scr

            for i in range(n):
                if simscores[i] == maxscore:
                    if maxteam == -1:
                        maxteam = i
                    else:
                        if names[i] < names[maxteam]:
                            maxteam = i
            could[maxteam] = 1

        return tuple(could)