結果
問題 | No.43 野球の試合 |
ユーザー |
![]() |
提出日時 | 2018-03-31 15:47:32 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,793 bytes |
コンパイル時間 | 95 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-06-26 01:36:00 |
合計ジャッジ時間 | 1,024 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 6 WA * 1 |
ソースコード
# -*- coding: utf-8 -*-"""No.43 野球の試合https://yukicoder.me/problems/no/43"""import sysfrom sys import stdininput = stdin.readlinedef update_status(N, result):# 残り試合があるチーム情報を[現時点での勝ち星数, チーム番号]でリスト化res = []for i, row in enumerate(result[1:], start=1):if '-' in row:win = row.count('o')res.append([win, i])return resdef solve(N, result):# K君のチームに未消化の試合があれば全勝したことにするfor x in range(N):if result[0][x] == '-':result[0][x] = 'o'result[x][0] = 'x'# 残り試合があるチームがあれば、残り試合を消化するremainings = update_status(N, result)while remainings:remainings.sort()_, t = remainings[-1] # 現時点で一番勝ち星数が多いチームをピックアップしてx = result[t].index('-')result[t][x] = 'x' # 1試合分負けたことにするresult[x][t] = 'o' # (対戦相手は勝ったことにする)remainings = update_status(N, result)# 他チームの勝ち星数をチェックwinnings = []for r in result[1:]:w = r.count('o')if w not in winnings:winnings.append(w)# 自分のチームの勝ち星数と比較して順位を決定するmy_winning = result[0].count('o')ans = 1for w in winnings:if w > my_winning:ans += 1return ansdef main(args):N = int(input())result = []for _ in range(N):result.append(list(input().strip()))ans = solve(N, result)print(ans)if __name__ == '__main__':main(sys.argv[1:])