結果

問題 No.29 パワーアップ
ユーザー 2329 N
提出日時 2020-09-04 19:17:26
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 692 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-26 11:24:06
合計ジャッジ時間 1,453 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
itm = []
for i in  range(n):
   itm += (list(map(int, input().split())))

#偶数個あるアイテムでのパワーアップ
p_1 = [itm.count(i) // 2 for i in set(itm) if itm.count(i) % 2 == 0]
p_1s = sum(p_1)

#奇数個あるアイテムでのパワーアップ(1個は数えず)
p_2 = [itm.count(i) // 2 for i in set(itm) if itm.count(i) % 2 == 1 and itm.count(i) != 1]
p_2s = sum(p_2) 

#その他でのパワーアップ
p_3 = [itm.count(i) % 2 for i in set(itm) if itm.count(i) % 2 == 1 and itm.count(i) != 1]
p_3s = sum(p_3) 

p_4 = [itm.count(i) for i in set(itm) if itm.count(i)  == 1]
p_4s = sum(p_4)

p_5s = (p_3s + p_4s) // 4

#ans
print(p_1s + p_2s + p_5s)
0