結果

問題 No.29 パワーアップ
ユーザー nanaenanae
提出日時 2017-01-01 11:02:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 20 ms / 5,000 ms
コード長 542 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 10,728 KB
実行使用メモリ 8,600 KB
最終ジャッジ日時 2023-08-22 09:08:49
合計ジャッジ時間 1,876 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,476 KB
testcase_01 AC 20 ms
8,456 KB
testcase_02 AC 18 ms
8,572 KB
testcase_03 AC 19 ms
8,520 KB
testcase_04 AC 18 ms
8,524 KB
testcase_05 AC 18 ms
8,596 KB
testcase_06 AC 19 ms
8,596 KB
testcase_07 AC 18 ms
8,584 KB
testcase_08 AC 18 ms
8,476 KB
testcase_09 AC 19 ms
8,568 KB
testcase_10 AC 19 ms
8,476 KB
testcase_11 AC 19 ms
8,472 KB
testcase_12 AC 19 ms
8,476 KB
testcase_13 AC 18 ms
8,528 KB
testcase_14 AC 19 ms
8,508 KB
testcase_15 AC 19 ms
8,568 KB
testcase_16 AC 19 ms
8,532 KB
testcase_17 AC 19 ms
8,600 KB
testcase_18 AC 19 ms
8,596 KB
testcase_19 AC 19 ms
8,564 KB
testcase_20 AC 19 ms
8,596 KB
testcase_21 AC 19 ms
8,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# yukicoder No.29 パワーアップ

from collections import Counter # 便利なCounterオブジェクトを使ってみる

# 入力部
N = int(input())
items = []
p_up = 0

for _ in range(N):
    items += input().split()
    
# 処理
num_items = Counter(items)

for (i, j) in num_items.items():
    p_up += j // 2 # 同じアイテム2つごとに+1
    num_items[i] = j % 2 # 余りを格納

p_up += sum(list(num_items.values())) // 4 # 余りの総和を4で割った回数だけパワーアップ

# 出力
print(p_up)
0