結果

問題 No.29 パワーアップ
ユーザー lam6er
提出日時 2025-03-31 17:48:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 432 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 53,852 KB
最終ジャッジ日時 2025-03-31 17:49:42
合計ジャッジ時間 1,842 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
counts = [0] * 10  # 1-based to 10, indexed 0-9

for _ in range(n):
    a, b, c = map(int, input().split())
    counts[a-1] += 1
    counts[b-1] += 1
    counts[c-1] += 1

# Calculate maximum pairs
pairs = sum(c // 2 for c in counts)

# Sum remaining items after pairs
remaining = sum(c % 2 for c in counts)

# Calculate quadruples from remaining
quadruples = remaining // 4

total = pairs + quadruples
print(total)
0