A. Bear and Five Cards

题目连接:

http://www.codeforces.com/contest/680/problem/A

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 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.

Sample Input

7 3 7 3 20

Sample Output

7 3 7 3 20

Hint

题意

你现在有五张牌,你可以删去相同的两张,或者三张,问你删去之后,这五张牌最小的和是多少?

题解:

模拟一遍就好了,模拟删除哪几张就行了……

代码

#include<bits/stdc++.h>
using namespace std; int n,x,sum,ans;
map<int,int>H;
int main()
{
n=5;
for(int i=0;i<n;i++){
scanf("%d",&x);
H[x]++;
sum+=x;
}
ans=sum;
for(auto v:H){
if(v.second>2)
ans=min(ans,sum-3*v.first);
if(v.second>1)
ans=min(ans,sum-2*v.first);
}
cout<<ans<<endl;
}

Codeforces Round #356 (Div. 2) A. Bear and Five Cards 水题的更多相关文章

  1. Codeforces Round #356 (Div. 2) C. Bear and Prime 100 水题

    C. Bear and Prime 100 题目连接: http://www.codeforces.com/contest/680/problem/C Description This is an i ...

  2. Codeforces Round #356 (Div. 2) B. Bear and Finding Criminal 水题

    B. Bear and Finding Criminals 题目连接: http://www.codeforces.com/contest/680/problem/B Description Ther ...

  3. 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 ...

  4. Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)

    Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...

  5. Codeforces Round #356 (Div. 2) C. Bear and Prime 100(转)

    C. Bear and Prime 100 time limit per test 1 second memory limit per test 256 megabytes input standar ...

  6. Codeforces Round #356 (Div. 2)B. Bear and Finding Criminals(水题)

    B. Bear and Finding Criminals time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  7. Codeforces Round #373 (Div. 2) C. Efim and Strange Grade 水题

    C. Efim and Strange Grade 题目连接: http://codeforces.com/contest/719/problem/C Description Efim just re ...

  8. Codeforces Round #185 (Div. 2) A. Whose sentence is it? 水题

    A. Whose sentence is it? Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

  9. Codeforces Round #373 (Div. 2) A. Vitya in the Countryside 水题

    A. Vitya in the Countryside 题目连接: http://codeforces.com/contest/719/problem/A Description Every summ ...

随机推荐

  1. ASP防XSS代码

    原作是在GitHub上,基于Node.js所写.但是..ASP的JS引擎跟V8又有些不同..于是,嗯.. <% Function AntiXSS_VbsTrim(s) AntiXSS_VbsTr ...

  2. 如何同步删除svn管理的package包目录

    转:https://blog.csdn.net/shiwodecuo/article/details/51754598 eclipse在实际的开发中,当我们的项目由svn进行管理时,若想删除选中的整个 ...

  3. 监听 手机back键和顶部的回退

    // 回退事件,监听 手机back键和顶部的回退 pushHistory(); window.addEventListener("popstate", function(e) { ...

  4. KMP模板及总结

    KMP是一种字符串匹配算法,它在时间复杂度上较暴力匹配算法由很大的优势.比如我要找字符串S中是否存在子串P,如果暴力匹配的话,则时间复杂度为O(n*m),而kmp算法时间复杂度为O(n+m). 这里我 ...

  5. redux-saga印象

    saga作为redux的中间件,用来处理异步任务. 先收集资料: 贴个文章(2)中的图先: 注意:参考文献(4)是redux-saga作者写的. 参考文章: (1)https://redux-saga ...

  6. chmod g+s 、chmod o+t 、chmod u+s:Linux高级权限管理

    关于linux下权限操作chmod的一些说明!比rxw高级内容! 转载自http://blog.chinaunix.net/uid-26642180-id-3378119.html Set uid, ...

  7. Metronic 5.0.5 bootstrap后台管理模板

    演示地址:http://keenthemes.com/preview/metronic/    下载 Dashboard Table

  8. USACO 6.4 The Primes

    The PrimesIOI'94 In the square below, each row, each column and the two diagonals can be read as a f ...

  9. Dubbo中只订阅与只注册

    一:只订阅 1.场景 为方便开发测试,经常会在线下共用一个所有服务可用的注册中心,这时,如果一个正在开发中的服务提供者注册,可能会影响消费者不能正常运行. 可以让服务提供者开发方,只订阅服务(开发的服 ...

  10. centos7 安装 supervisor

    一.安装 supervisor yum install python-setuptools easy_install supervisor 如果easy_install不好使就从官方下载: wget ...