本文整理汇总了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.