結果
問題 | No.709 優勝可能性 |
ユーザー |
![]() |
提出日時 | 2025-03-31 17:50:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 348 ms / 3,500 ms |
コード長 | 1,687 bytes |
コンパイル時間 | 329 ms |
コンパイル使用メモリ | 82,376 KB |
実行使用メモリ | 203,068 KB |
最終ジャッジ日時 | 2025-03-31 17:50:55 |
合計ジャッジ時間 | 5,833 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
def main():import sysinput = sys.stdin.readdata = input().split()idx = 0N = int(data[idx])M = int(data[idx + 1])idx += 2R = []for _ in range(N):R.append(list(map(int, data[idx:idx + M])))idx += Mcurrent_max_val = [0] * Mcurrent_max_people = [set() for _ in range(M)]active = [0] * (N + 2) # 1-based indexingresult = 0answers = []for k in range(1, N + 1):row = R[k-1]for j in range(M):val = row[j]if val > current_max_val[j]:# Process previous max peopleprev_people = current_max_people[j]for i in prev_people:old = active[i]active[i] -= 1new = active[i]if old == 1 and new == 0:result -= 1current_max_people[j].clear()current_max_val[j] = valcurrent_max_people[j].add(k)# Now add kold = active[k]active[k] += 1new = active[k]if old == 0 and new == 1:result += 1elif val == current_max_val[j]:if k not in current_max_people[j]:current_max_people[j].add(k)old = active[k]active[k] += 1new = active[k]if old == 0 and new == 1:result += 1answers.append(result)for ans in answers:print(ans)if __name__ == '__main__':main()