結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー maspy
提出日時 2020-03-22 06:34:51
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 957 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 44,576 KB
最終ジャッジ日時 2024-12-24 16:38:46
合計ジャッジ時間 12,064 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
m = map(int, read().split())
X, A, B = zip(*zip(m, m, m))
X = [x + 1 for x in X]
U = 10 ** 5 + 1

A_to_I = [[] for _ in range(U)]
B_to_I = [[] for _ in range(U)]
for i, a in enumerate(A):
    A_to_I[a].append(i)

for i, b in enumerate(B):
    B_to_I[b].append(i)

counts = [0, 0, 0, 0, 0, 0]
for x in X:
    counts[x] += 1

A = 0
B = 10 ** 5 + 1

answer = 10 ** 9
while True:
    if A >= U:
        break
    if sum(counts[2:]) >= M and sum(counts[3:]) < answer:
        answer = sum(counts[3:])
    for i in A_to_I[A]:
        counts[X[i]] -= 1
        X[i] -= 1
        counts[X[i]] += 1
    A += 1
    while B > 0 and sum(counts[2:]) < M:
        B -= 1
        for i in B_to_I[B]:
            counts[X[i]] -= 1
            X[i] += 1
            counts[X[i]] += 1

print(answer)
0