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 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 水题的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)
Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...
- 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 ...
- 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 ...
- 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 ...
- 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/ ...
- 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 ...
随机推荐
- 64_t7
texlive-ulqda-bin-svn13663.0-33.20160520.fc26.2..> 24-May-2017 15:57 33102 texlive-ulqda-doc-svn2 ...
- [HBase]region split流程
1. 简介 HBase 的最小管理单位为region,region会按照region 分裂策略进行分裂. 基于CDH5.4.2 2. 总览
- Python开发环境(1):Eclipse+PyDev插件
电脑:小米笔记本电脑Pro 15.6寸(i5-8250U),操作系统:Windows 10,JDK版本:1.8.0_152(环境变量已配置) Step 1.下载Eclipse 根据我的CPU型号,选择 ...
- pip install 升级时候 出现报asciii码错误的问题。
原因是pip安装python包会加载我的用户目录,我的用户目录恰好是中文的,ascii不能编码.解决办法是: python目录 Python27\Lib\site-packages 建一个文件site ...
- 基于vue配置axios
转载地址:https://juejin.im/post/5a02a898f265da43052e0c85 1.背景 在项目开发中ajax请求是必不可缺少 一部分ajax请求不需要loading或则请求 ...
- JS实现全选、反选、不选
JS实现全选.反选.不选 效果图: 代码如下,复制即可使用: <!DOCTYPE html> <html> <head> <meta charset=&quo ...
- Java 从多层嵌套中访问内部类的成员
一个内部类被嵌套多少层并不重要--它能透明地访问所有它能嵌入的外围类的所有成员 //: innerclasses/MultiNestingAccess.java // Nested classes c ...
- (三)Rest风格的资源URL
第一节:Restful风格的资源URL简介 第二节:SpringMVC对Rest风格的支持 第三节:@PathVariable获取Url变量 第四节:SpringMVC对静态资源的处理 http:// ...
- Baidu软件研发工程师笔试题整理
Hadoop Map/Reduce Hadoop Map/Reduce是一个使用简易的软件框架,基于它写出来的应用程序能够运行在由上千个商用机器组成的大型集群上,并以一种可靠容错的方式并行处理上T级别 ...
- Metronic 5.0.5 bootstrap后台管理模板
演示地址:http://keenthemes.com/preview/metronic/ 下载 Dashboard Table