結果
問題 |
No.59 鉄道の旅
|
ユーザー |
|
提出日時 | 2017-02-15 10:07:32 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 821 bytes |
コンパイル時間 | 139 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 23,424 KB |
最終ジャッジ日時 | 2024-12-29 22:52:50 |
合計ジャッジ時間 | 20,612 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 9 TLE * 3 |
ソースコード
#-*- coding: utf-8 -*- class Train(): def __init__(self, K): self.cargo = [] self.K = K def load(self, weight): if len(self.cargo) < self.K: self.cargo.append(weight) self.cargo.sort() elif self.cargo[-self.K] < weight: self.cargo.append(weight) self.cargo.sort() return None def unload(self, weight): if weight in self.cargo: i = self.cargo.index(weight) del self.cargo[i] return None def station(ft, W): if W > 0: ft.load(W) else: ft.unload(-W) def main(N, K): ft = Train(int(K)) for i in range(int(N)): W = int(input()) station(ft, W) return len(ft.cargo) if __name__ == '__main__': print(main(*(input().split())))