結果
| 問題 | No.568 じゃんじゃん 落とす 委員会 | 
| コンテスト | |
| ユーザー |  maspy | 
| 提出日時 | 2020-03-22 06:35:35 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 600 ms / 1,000 ms | 
| コード長 | 948 bytes | 
| コンパイル時間 | 86 ms | 
| コンパイル使用メモリ | 12,928 KB | 
| 実行使用メモリ | 44,440 KB | 
| 最終ジャッジ日時 | 2024-12-24 16:39:31 | 
| 合計ジャッジ時間 | 11,898 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 26 | 
ソースコード
#!/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 + 10
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 = U
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)
            
            
            
        