C - Bear and Five Cards
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
Input7 3 7 3 20Output26Input7 9 3 1 8Output28Input10 10 10 10 10Output20
题意:共有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的更多相关文章
- 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 680A A. Bear and Five Cards(水题)
题目链接: A. Bear and Five Cards //#include <bits/stdc++.h> #include <vector> #include <i ...
- 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 ...
- [ An Ac a Day ^_^ ] CodeForces 680A Bear and Five Cards
这两天回家了 家里电脑太卡 调试不方便 就只能写写水题了…… #include<stdio.h> #include<iostream> #include<algorith ...
- 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 ...
- Codeforces Round #356 (Div. 2)-A
A. Bear and Five Cards 题目链接:http://codeforces.com/contest/680/problem/A A little bear Limak plays a ...
- Codeforces Round #356 (Div. 2)
A. Bear and Five Cards time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- BZOJ 1004 【HNOI2008】 Cards
题目链接:Cards 听说这道题是染色问题的入门题,于是就去学了一下\(Bunside\)引理和\(P\acute{o}lya\)定理(其实还是没有懂),回来写这道题. 由于题目中保证"任意 ...
- 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 ...
随机推荐
- 基于Redis缓存的Session共享测试(转)
本机ip为192.168.1.101 1.准备测试环境 两个Tomcat 在Eclipse中新建2个Servers,指定对应的Tomcat,端口号错开. Tomcat1(18005.18080.180 ...
- 谈谈 T 型人才
谈谈 T 型人才 昨天的图片发模糊了,正好我把这个话题展开聊一聊吧.这个话题是关于复合型人才的,我把它称作 T 型人才. 「全栈」工程师 前一段时间,「全栈」工程师的概念很火,不过大多数时候,「全 ...
- C#获取Access数据库中的所有表名和列名
//C#获取Access数据库中的所有表名和列名 string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" ...
- 根据百度地图API获取指定地点的经纬度
做项目时,遇到对地点获取地图中对应的经纬度,作一下笔记,以备以后直接使用 package com.hpzx.data; import java.io.BufferedReader; import ja ...
- teradata培训文档 相关索引
teradata培训文档 http://wenku.baidu.com/view/ec44c201cc175527072208ba.html Teradata 和Greenplum 的讨论 http: ...
- Android 四大组件学习之BroadcastReceiver一
本节课学习四大组件最后一个, 广播接受者. 顾名思义广播接受者就是接受广播呗.比方在现实社会中,曾经每一个人家都有一台收音机,这可就能够去接受广播发出来的消息.大家都知道.程序世界也是參照的显示生活设 ...
- raise 与 raise ... from 的区别
起步 Python 的 raise 和 raise from 之间的区别是什么? try: print(1 / 0) except Exception as exc: raise RuntimeErr ...
- Android系统编译错误Note: Some input files use or override a deprecated API. 解决办法【转】
本文转载自:http://blog.csdn.net/lilidejing/article/details/46564491 进入系统framework层修改了下MediaPlayer.java的源码 ...
- sdut oj 排队买饭
数据结构实验之队列一:排队买饭 Time Limit: 1000MS Memory limit: 65536K 题目描述 中午买饭的人特多,食堂真是太拥挤了,买个饭费劲,理工大的小孩还是很聪明的,直接 ...
- CodeChef Forest Gathering —— 二分
题目链接:https://vjudge.net/problem/CodeChef-FORESTGA 题解: 现场赛.拿到这题很快就知道是二分,但是一直wa,怎么修改也wa,后来又换了种错误的思路,最后 ...