A10404 | Bear and Five Cards
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 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?
输入格式
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.
输出格式
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$ .
- 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$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted