CF680A.Bear and Five Cards

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

Given five numbers written on cards, cay you find the minimum sum of numbers on remaining cards?

一只小熊 Limak 正在玩一个游戏。他有五张卡片,每张卡片上写有一个数字,每个数字均为正整数。

Limak 可以丢弃(扔掉)一些卡片。他的目标是使剩余(未被丢弃)卡片上的数字之和尽可能小。

他最多可以执行一次操作:丢弃两张或三张数字相同的卡片。当然,如果无法选出两张或三张数字相同的卡片,他就不会丢弃任何卡片。

给定五张卡片上的五个数字,请你求出剩余卡片上数字之和的最小可能值?

输入格式

The only line of the input contains five integers _t_1, _t_2, _t_3, _t_4 and _t_5 (1 ≤ t__i ≤ 100) — numbers written on cards.

输入仅有一行,包含五个整数 t1t_1、t2t_2、t3t_3、t4t_4 和 t5t_5(1 ≤ ti ≤ 1001 ≤ t_i ≤ 100)—— 卡片上写的数字。

输出格式

Print the minimum possible sum of numbers written on remaining cards.

输出剩余卡片上数字的最小可能总和。

输入输出样例

  • 输入#1

    7 3 7 3 20

    输出#1

    26
  • 输入#2

    7 9 3 1 8

    输出#2

    28
  • 输入#3

    10 10 10 10 10

    输出#3

    20

说明/提示

In the first sample, Limak has cards with numbers 7, 3, 7, 3 and 20. Limak can do one of the following.

  • Do nothing and the sum would be 7 + 3 + 7 + 3 + 20 = 40.
  • Remove two cards with a number 7. The remaining sum would be 3 + 3 + 20 = 26.
  • Remove two cards with a number 3. The remaining sum would be 7 + 7 + 20 = 34.

You are asked to minimize the sum so the answer is 26.

In the second sample, it's impossible to find two or three cards with the same number. Hence, Limak does nothing and the sum is 7 + 9 + 1 + 3 + 8 = 28.

In the third sample, all cards have the same number. It's optimal to discard any three cards. The sum of two remaining numbers is 10 + 10 = 20.

在第一个样例中,Limak 拥有数字为 77、33、77、33 和 2020 的卡片。Limak 可以执行以下操作之一:

  • 什么都不做,此时总和为 7 + 3 + 7 + 3 + 20 = 407 + 3 + 7 + 3 + 20 = 40。
  • 移除两张数字为 77 的卡片,剩余总和为 3 + 3 + 20 = 263 + 3 + 20 = 26。
  • 移除两张数字为 33 的卡片,剩余总和为 7 + 7 + 20 = 347 + 7 + 20 = 34。

题目要求使总和最小,因此答案为 2626。

在第二个样例中,无法找到两张或三张数字相同的卡片。因此,Limak 什么也不做,总和为 7 + 9 + 1 + 3 + 8 = 287 + 9 + 1 + 3 + 8 = 28。

在第三个样例中,所有卡片的数字均相同。最优策略是丢弃任意三张卡片,剩余两张卡片的数字之和为 10 + 10 = 2010 + 10 = 20。

输入解题思路,AI测评打分。不知道怎么写?

首页