本文整理匯總了Python中collections.Counter.items方法的典型用法代碼示例。如果您正苦於以下問題:Python Counter.items方法的具體用法?Python Counter.items怎麽用?Python Counter.items使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類collections.Counter
的用法示例。
在下文中一共展示了Counter.items方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: tuple
# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import items [as 別名]
from sys import stdin as Si, maxsize as m
from math import floor as F
from collections import defaultdict as dt, Counter as Co
from operator import itemgetter as ig
from math import pi
if __name__ == "__main__":
L = tuple(map(int, Si.readline().split()))
H, Max = Co(L), 0
for k, v in H.items():
if v > 1:
Max = max(Max, k * min(v, 3))
print(sum(L) - Max)
"""
A. Bear and Five Cards
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer.
Limak can discard (throw out) some cards. His goal is to minimize the sum of numbers written on remaining (not discarded) cards.
He is allowed to at most once discard two or three cards with the same number. Of course, he won't discard cards if it's impossible to choose two or three cards with the same number.