Description

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 t1t2t3t4 and t5 (1 ≤ ti ≤ 100) — numbers written on cards.

Output

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

Sample Input

Input
7 3 7 3 20
Output
26
Input
7 9 3 1 8
Output
28
Input
10 10 10 10 10
Output
20

题意:共有5张卡,可将两张或三张重复卡片扔掉,求扔掉后和的最小值。

排序后找到最大重复卡片和减掉即可。

附AC代码:

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std; int a[];
int main(){
for(int i=;i<;i++){
cin>>a[i];
}
sort(a,a+);
int ans=,Max=,sum=;
for(int i=;i<;i++){
if(a[i]==a[i+]){
if(ans<=)//最多扔三张
Max=max(Max,a[i]*ans);
ans++;
}
else
ans=;
}
for(int i=;i<;i++){
sum+=a[i];
}
cout<<sum-Max<<endl;
return ;
}

C - Bear and Five Cards的更多相关文章

  1. Codeforces Round #356 (Div. 2)A. Bear and Five Cards(简单模拟)

    A. Bear and Five Cards time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  2. codeforces 680A A. Bear and Five Cards(水题)

    题目链接: A. Bear and Five Cards //#include <bits/stdc++.h> #include <vector> #include <i ...

  3. Codeforces Round #356 (Div. 2) A. Bear and Five Cards 水题

    A. Bear and Five Cards 题目连接: http://www.codeforces.com/contest/680/problem/A Description A little be ...

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

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

  5. A- Bear and Five Cards(codeforces ROUND356 DIV2)

    A. Bear and Five Cards time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  6. Codeforces Round #356 (Div. 2)-A

    A. Bear and Five Cards 题目链接:http://codeforces.com/contest/680/problem/A A little bear Limak plays a ...

  7. Codeforces Round #356 (Div. 2)

    A. Bear and Five Cards time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  8. BZOJ 1004 【HNOI2008】 Cards

    题目链接:Cards 听说这道题是染色问题的入门题,于是就去学了一下\(Bunside\)引理和\(P\acute{o}lya\)定理(其实还是没有懂),回来写这道题. 由于题目中保证"任意 ...

  9. Codeforces CF#628 Education 8 F. Bear and Fair Set

    F. Bear and Fair Set time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

随机推荐

  1. Android性能优化之中的一个 布局优化

    本文为Android性能优化--布局优化,主要介绍使用抽象布局标签(include, viewstub, merge).去除不必要的嵌套和View节点.降低不必要的infalte及其它Layout方面 ...

  2. C++输入一行字符串的一点小结

    C++输入一行字符串的一点小结 原文链接: http://www.wutianqi.com/?p=1181 大家在学习C++编程时.一般在输入方面都是使用的cin. 而cin是使用空白(空格,制表符和 ...

  3. Struts2 原理(转载)

    图来源于Struts2官方站点,是Struts 2 的整体结构. Struts2框架由3个部分组成:核心控制器FilterDispatcher.业务控制器和用户实现的业务逻辑组件.在这3个部分里,St ...

  4. wpf中的样式与模板

    1.WPF样式类似于Web应用程序中的CSS,在WPF中可以为控件定义统一的样式(Style).样式属于资源的一种,例如为Button定义统一的背景颜色和字体: <Window.Resource ...

  5. 为自己编写的windows应用程序制作安装包

    1 写好了一个windows程序之后如何制作安装包 这个在vs中就可以直接发布了,可以制作msi的安装包和exe的安装包. 2 window应用程序安装包做了哪些事情 rpm安装包的话,只是把相应的文 ...

  6. WF中的Bookmark

    最近在学习WF, 把自己的一些学习心得放上来 Bookmark允许你以事件驱动的方式与一个Workflow内的Activity进行交互. 如果把启动一个workflow比做开始读一本书, 在Workf ...

  7. 寻找JAVA_HOME find java

    more apache-flume-1.8.0-bin/bin/flume-ng # find java if [ -z "${JAVA_HOME}" ] ; then warn ...

  8. Boosting AdaBoosting Algorithm

    http://math.mit.edu/~rothvoss/18.304.3PM/Presentations/1-Eric-Boosting304FinalRpdf.pdf Consider MIT ...

  9. 向sd卡读写数据

    /data/data 是本地存储 /storage/ 是外部存储 SD卡存储 <uses-permission android:name="android.permission.WRI ...

  10. Linux随笔-鸟哥Linux服务器篇学习总结(全)

    作者:Danbo 时间:2015-7-17 在runlevel3启动级别下默认启动网络挂载(autofs)机制,我们可以通过命令将其关闭:chkconfig autofs off 或者 /etc/in ...