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. C#基础关键字

    1:override & new public class A { public virtual void Test() { Console.WriteLine("A Test()& ...

  2. vs2012停止调试长时间不响应问题解决方法

    在vs2012命令提示符下,运行devenv.exe /resetuserdata又一次设置下环境解决.

  3. bb=Discuz与 Discuz! X ,Discuz!NT区别

    没加x的,仅仅是单独的论坛. 加了x的,模块加了很多了,门户,家园,排行榜,群组,都是Discuz! X上的,而Discuz!上没有,所以说Discuz! X更加适用于建设门户网 Discuz! X ...

  4. SQL Cursor生命周期

      阅读导航 1 Cursor Step 1.1 Create cursor 1.2 Parse statement 1.3 descript and define 1.4 Bind variable ...

  5. Scrapyd部署

    从github(https://github.com/scrapy/scrapyd)下载安装包放到D:\python\Lib\site-packages\ 解压压缩包:cd 到解压目录 python ...

  6. 淘宝客网站SEO及赚钱与揭密

  7. ftp上传文件不能上传到指定的文件夹

    首先是,使用ftp创建连接,这一点没有错误,但是在切换目录创建文件夹的时候出现了问题. 指定创建的文件夹,总是创建失败,切换目录同样失败.最后查看文件夹的权限才知道,没有权限的问题: 然后给img文件 ...

  8. java读流方式,下载网络上的图片

    本工具类支持url的list集合,具体实现如下所示: public static void download(ArrayList<String> listUrl, String downl ...

  9. linux系统上安装svn服务器 环境linux+nginx+svnserver

    系统:Ubuntu 12.04 64位 lnmp环境 集成软件:PHP5.4.27.Nginx1.6.0.MySQL5.5.37 阿里云server svnserver有2种执行方式:独立server ...

  10. ZFIND_ENHANCEMENT(找增强点-新)

    REPORT ZFIND_ENHANCEMENT. *&-------------------------------------------------------------------- ...