結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー fgshunfgshun
提出日時 2021-01-04 12:09:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,066 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 14,080 KB
最終ジャッジ日時 2024-04-22 15:53:13
合計ジャッジ時間 3,320 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
12,160 KB
testcase_01 AC 47 ms
12,288 KB
testcase_02 AC 48 ms
12,288 KB
testcase_03 AC 53 ms
12,544 KB
testcase_04 AC 52 ms
12,416 KB
testcase_05 AC 66 ms
13,440 KB
testcase_06 AC 75 ms
13,824 KB
testcase_07 AC 59 ms
12,800 KB
testcase_08 AC 62 ms
13,184 KB
testcase_09 AC 71 ms
13,696 KB
testcase_10 AC 51 ms
12,544 KB
testcase_11 AC 54 ms
12,416 KB
testcase_12 AC 57 ms
12,800 KB
testcase_13 AC 65 ms
13,568 KB
testcase_14 AC 73 ms
13,824 KB
testcase_15 AC 54 ms
12,416 KB
testcase_16 AC 52 ms
12,672 KB
testcase_17 AC 53 ms
12,544 KB
testcase_18 AC 49 ms
12,416 KB
testcase_19 AC 79 ms
14,080 KB
testcase_20 AC 72 ms
13,824 KB
testcase_21 AC 53 ms
12,672 KB
testcase_22 AC 53 ms
12,544 KB
testcase_23 AC 56 ms
12,672 KB
testcase_24 AC 69 ms
13,440 KB
testcase_25 AC 77 ms
13,824 KB
testcase_26 AC 60 ms
12,928 KB
testcase_27 AC 59 ms
12,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import islice
from collections import defaultdict
from dataclasses import dataclass


def _score(star, rank):
    return 50 * star + int((500 * star) // (8 + 2 * rank))


def _solve(N, L, T, queries):
    key = lambda a: (a[-2], -a[-1])
    scores = defaultdict(lambda: [''] + [0] * (N + 2))
    rank = [0] * N

    c_a = ord('A')
    for i, (name, q) in enumerate(queries):
        index = ord(q) - c_a
        rank[index] += 1
        score = _score(L[index], rank[index])

        scores[name][0] = name
        scores[name][index + 1] = score
        scores[name][-2] += score
        scores[name][-1] = i

    return enumerate(sorted(scores.values(), key=key, reverse=True), 1)


def solve(in_):
    N = int(next(in_))
    L = tuple(map(int, next(in_).split()))
    T = int(next(in_))
    queries = (line.split() for line in islice(in_, T))

    return _solve(N, L, T, queries)
    

def main():
    answer = solve(sys.stdin)
    for i, v in answer:
        print(i, ' '.join(map(str, v[:-1])))


if __name__ == '__main__':
    main()
0