結果

問題 No.709 優勝可能性
コンテスト
ユーザー roaris
提出日時 2021-06-02 11:54:09
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 167 ms / 3,500 ms
コード長 751 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 304 ms
コンパイル使用メモリ 84,992 KB
実行使用メモリ 107,520 KB
最終ジャッジ日時 2026-05-10 02:18:03
合計ジャッジ時間 5,460 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline
from collections import *

N, M = map(int, input().split())
Ma = [0]*M
cnt = [0]*N
ans = 0
idx = [defaultdict(list) for _ in range(M)]

for i in range(N):
    R = list(map(int, input().split()))
    
    for j in range(M):
        if R[j]==Ma[j]:
            if cnt[i]==0:
                ans += 1
            
            cnt[i] += 1
            idx[j][Ma[j]].append(i)
        elif R[j]>Ma[j]:
            for k in idx[j][Ma[j]]:
                cnt[k] -= 1
                
                if cnt[k]==0:
                    ans -= 1
            
            if cnt[i]==0:
                ans += 1
            
            cnt[i] += 1
            Ma[j] = R[j]
            idx[j][Ma[j]].append(i)

    print(ans)
0