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 ...
随机推荐
- 串口流控制详解(CTS/RTS,DTR/DSR)
1 首先看下关于流控相关的几个端口的解释如下图 除了必要的地(GND)要连接外,其它连如下 步骤阅读 2 计算机和猫(MODEM)的连接 步骤阅读 步骤阅读 3 计算机和非猫的连接(null mod ...
- vue总结 06组件
组件基础 基本示例 这里有一个 Vue 组件的示例: // 定义一个名为 button-counter 的新组件Vue.component('button-counter', { data: func ...
- 数据库-mysql储存过程
存储过程是一个SQL语句集合,当主动去调用存储过程时,其中内部的SQL语句会按照逻辑执行. 一:创建存储过程 MariaDB [test2]> delimiter // MariaDB [tes ...
- 数据库-mysql数据连接
一:Mysql 连接的使用 在前几章节中,我们已经学会了如果在一张表中读取数据,这是相对简单的,但是在真正的应用中经常需要从多个数据表中读取数据. 本章节我们将向大家介绍如何使用 MySQL 的 JO ...
- xgboost gbdt特征点分烈点
lightGBM与XGBoost的区别:(来源于:http://baijiahao.baidu.com/s?id=1588002707760744935&wfr=spider&for= ...
- No.17 selenium学习之路之判断与等待
一.三种等待方式 1.sleep 加载time库.time.sleep() 休眠单位以秒为单位 2.implicitly_wait() 等待页面完全加载完成(左上角转圈结束) 参数为等待时间,等待页面 ...
- PreparedStatement 查询 In 语句 setArray 等介绍。
ps = conn.prepareStatement("SELECT tid,jdp_response FROM jdp_tb_trade WHERE tid IN (?) ORDER BY ...
- CSDN博客专家申请成功
又一个值得纪念的日子,上周六申请CSDN博客专家,今天中午审批通过.使用CSDN好几年了,从未想到能把博客一步步的写到这个地步. 曾经,写过一段博客,只是为了记录和分享.中间由于工作的变动和繁忙中断了 ...
- JAVA 解析TXT文本
package file; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; im ...
- 【TensorFlow】Python解析xml文件
最近在项目中使用TensorFlow训练目标检测模型,在制作自己的数据集时使用了labelimg软件对图片进行标注,产生了VOC格式的数据,但标注生成的xml文件标签值难免会产生个别错误造成程序无法跑 ...