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. Ajax 跨域难题 - 原生 JS 和 jQuery 的实现对比

    讲解顺序: AJAX 的概念及由来 JS 和 jQuery 中的 ajax 浏览器机制 AJAX 跨域 AJAX 的概念 在讲解 AJAX 的概念之前,我先提一个问题. 这是一个典型的 B/S 模式. ...

  2. 7.2 HAVING子句

    7.2 HAVING子句正在更新内容.请稍后

  3. 用callgraph生成的两张函数调用关系图

    参考这里,感觉很Cool吧. Linux-0.11函数调用关系图: QEMU函数调用关系图:

  4. H5 手机横竖屏判读

    $.fn.screenCheck = function() { var pDiv = $('<div></div>'); pDiv.addClass("screenC ...

  5. WWDC2014苹果的“软件”发布会

    WWDC 2014 苹果的"软件"发布会 在今年的 6 月 2 日到 6 日,苹果照例举行了一年一次的全球开发者大会(World Wide Developer Conference ...

  6. git 安装及命令

    一.window下的git安装 1.安装教程 网上教程一堆.我參考的是这个:Git_Windows 系统下Git安装图解 还有这个也不错 2.环境搭建: 在配置完毕后,自己主动载入到系统环境变量中.如 ...

  7. 解读OC中的load和initialize

    在 Objective-C 中,NSObject 是绝大多数类的基类.而在 NSObject 中有两个类方法 load 和 initialize,那这两个方法是在什么时机被调用呢?父类.Categor ...

  8. 最新wap手机agent

    名称 agent 铃声格式 和弦数 数据量 删除 LGE-CU8080  LGE-CU8080/1.0 UP.Browser/4.1.26l UP.Link/5.1.2.9  pmd2.0  40   ...

  9. Leetcode 002-Search Insert Position

    #Given a sorted array and a target value, return the index if the target is found. If not, return th ...

  10. lua 定义类 就是这么简单

    在网上看到这样一段代码,真是误人子弟呀,具体就是: lua类的定义 代码如下: local clsNames = {} local __setmetatable = setmetatable loca ...