点击打开链接

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.

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

Input

The only line of the input contains five integers t1, t2, t3, t4 and t5 (1 ≤ ti ≤ 100) — numbers written on cards.

Output

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

Examples
input

Copy

7 3 7 3 20

output

Copy

26

input

Copy

7 9 3 1 8

output

Copy

28

input

Copy

10 10 10 10 10

output

Copy

20

Note

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.

水题

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
int main()
{  // freopen("shuju.txt","r",stdin);int a[10];memset(a,0,sizeof(a));int sum=0;for(int i=1;i<=5;i++){cin>>a[i];sum+=a[i];}sort(a+1,a+1+5);int mi=sum;for(int i=5;i>1;i--){if(a[i]==a[i-1]&&a[i]==a[i-2]){mi=min(mi,sum-a[i]*3);}if(a[i]==a[i-1]){mi=min(mi,sum-a[i]*2);}}  cout<<mi<<endl;return 0;
}

codeforces 680A Bear and Five Cards相关推荐

  1. [ An Ac a Day ^_^ ] CodeForces 680A Bear and Five Cards

    这两天回家了 家里电脑太卡 调试不方便 就只能写写水题了-- 1 #include<stdio.h> 2 #include<iostream> 3 #include<al ...

  2. CodeForces 658C Bear and Forgotten Tree 3(构造)

    题意:构造一棵树,有N个点,直径为d,深度为h 思路:首先构造一个长度为d的链,然后把其中一个距离边上为h的点变为根.然后我们就不停的在距离根为h上面的那一点不停的加点就好了,使得新加入的点的距离也为 ...

  3. Codeforces A - Bear and Prime 100(交互题)

    A - Bear and Prime 100 思路:任何一个合数都可以写成2个以上质数的乘积.在2-100中,除了4,9,25,49外都可以写成两个以上不同质数的乘积. 所以打一个质数加这四个数的表: ...

  4. Codeforces 658D Bear and Polynomials【数学】

    题目链接: http://codeforces.com/contest/658/problem/D 题意: 给定合法多项式,改变一项的系数,使得P(2)=0,问有多少种方法? 分析: 暴力求和然后依次 ...

  5. 【CodeForces - 546C 】Soldier and Cards (模拟)

    题干: Two bored soldiers are playing card war. Their card deck consists of exactly n cards, numbered f ...

  6. Codeforces——791A Bear and Big Brother

    小声BB 又开始更新了,最近打游戏王DL,这个栏目会留一些上分的心得. 题干 time limit per test:1 second memory limit per test:256 megaby ...

  7. Codeforces A. Bear and Big Brother

    ...不行.这题之后.不做1000分以下的了.很耻辱 A. Bear and Big Brother time limit per test 1 second memory limit per tes ...

  8. CodeForces 679B Bear and Tower of Cubes

    $dfs$,贪心. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> # ...

  9. codeforces 356C Bear and Square Grid

    说是一个k的方块,里面的都可以变成点,问最大的联通块. 2A的原因是这个有意思的删点,联通块里的点不能有一个不在就直接删除,而是要标记一下,都出去了才能删除.机智. 大概思路就是,预处理每个联通快,完 ...

最新文章

  1. html5页面输出语句,使用html5输出文件
  2. 肝!一款基于 Python 语言的 Linux 资源监视器!
  3. 如何将 Linq 的查询结果转为 HashSet ?
  4. 认知:什么是真正的产品思维?
  5. jQuery选择id属性带有.点符号元素的方法
  6. 4014-基于邻接表的长度为k的简单路径的求解(C++,附思路)
  7. FFmpeg Android 学习(一):Android 如何调用 FFMPEG 编辑音视频
  8. 华为笔记本没有网线口_3599元起,华为台式机MateStation B515上架:R5 4600G
  9. percona mysql 编译参数_Linux 下编译安装 MySQL(Percona Server) 5.6
  10. set vue 修改整个对象值_Vue修改对象或数据,页面没有相应更改
  11. robocode_Robocode大师的提示,技巧和建议的集合
  12. 开源自己的一个小android项目(美女撕衣服游戏)
  13. 第一章 SDN介绍 (附件1 )【华为SDN产业链分析】
  14. android EditText的美化
  15. alt+f2无法切换 linux,X 冻结: 无法通过 Ctrl + Alt + F2/F3 切换到虚拟终端(其实已经切过去了, 只是屏幕没有更新)...
  16. 面试官再问线程池,你这样谈谈线程的回收,好感会倍增!
  17. Contrastive Model Inversion for Data-Free Knowledge Distillation
  18. mac安装homebrew + git + nodejs
  19. 2021年安装deepin20.3和windows双系统
  20. 解决svn: E170001报错

热门文章

  1. 《数据采集与分析》期末考试爬虫部分重要知识点复习(详细版)
  2. 自学 Python 两个月的总结
  3. 大学里最浪费生命的十件事
  4. 爬虫周学习总结__赵俊杰
  5. 智能多用型防虹吸性能试验装置正式研发成功
  6. 2计算机电源机,2分钟解读,电脑装机电源如何选?
  7. android Vibrator 震动器 使用
  8. 方程式 Eternalblue 漏洞利用复现
  9. 逻辑斯蒂回归(对数几率回归)
  10. GMM-UBM for single-speaker detection