Codeforces Round #356 (Div. 2)A. Bear and Five Cards(简单模拟)
2 seconds
256 megabytes
standard input
standard output
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?
The only line of the input contains five integers t1, t2, t3, t4 and t5 (1 ≤ ti ≤ 100) — numbers written on cards.
Print the minimum possible sum of numbers written on remaining cards.
7 3 7 3 20
26
7 9 3 1 8
28
10 10 10 10 10
20 链接:http://codeforces.com/contest/680/problem/A 这是我第一次打cf,做出了div2的A和B,感觉还不错,虽然都很水= =这题看懂了题意之后就是简单的模拟了,我写的代码重复率比较高,大多是复制粘贴的,现在也懒得改了,也许这样能看的更清楚呢!!
只不过这么长的代码,我也是佩服我自己当时能写出来,可能是对于我来说,半夜写代码更有效率吧,,,呵呵。
#include<bits/stdc++.h>
using namespace std; #define Rep(i,a,b) for(int i=(a);i<=(b);i++) int mmin(int a,int b,int c)
{
return min(a,min(b,c));
} int main()
{
int a[]= {};
set<int> sei;
for (int i=; i<=; i++)
{
cin>>a[i];
sei.insert(a[i]);
}
int sum=;
set<int>::iterator its;
if (sei.size()==)
{
Rep(i,,)
sum+=a[i];
printf("%d\n",sum);
return ;
}
else
{
if (sei.size()==)
{
sum=*a[];
printf("%d\n",sum);
return ;
}
else if (sei.size()==)
{
int a1=,a2=;
int te[]={};
int id;
for (its=sei.begin(),id=;its!=sei.end();id++,its++)
{
te[id]=*its;
}
Rep(i,,)
{
if (a[i]==te[])
a1++;
else if (a[i]==te[])
a2++;
}
if (a1==||a1==)
{
printf("%d\n",te[]+te[]);
return ;
}
else if (a1==)
{
printf("%d\n",min(te[]*,*te[]));
return ;
}
else if (a1==)
{
printf("%d\n",min(te[]*,te[]*));
return ;
}
}
else if (sei.size()==)
{
int a1=,a2=,a3=;
int te[]={};
int id;
for (its=sei.begin(),id=;its!=sei.end();id++,its++)
{
te[id]=*its;
}
Rep(i,,)
{ if (a[i]==te[])
a1++;
else if (a[i]==te[])
a2++;
else if (a[i]==te[])
a3++;
}
int f1=te[];
int f2=te[];
int f3=te[];
if (a1==&&a2==)
{
printf("%d\n",f1+f2);
return ;
}
else if (a1==&&a2==)
{
printf("%d\n",min(f1+*f3,f1+*f2));
return ;
}
else if (a1==&&a2==)
{
printf("%d\n",f1+f3);
return ;
}
else if (a1==&&a2==)
{
printf("%d\n",min(f2+*f3,f2+*f1));
return ;
}
else if (a1==&&a2==)
{
printf("%d\n",min(*f1+f3,*f2+f3));
return ;
}
else if (a1==&&a2==)
{
printf("%d\n",f2+f3);
return ;
}
}
else if (sei.size()==)
{
int a1=,a2=,a3=,a4=;
int te[]={};
int id;
for (its=sei.begin(),id=;its!=sei.end();id++,its++)
{
te[id]=*its;
}
Rep(i,,)
{
if (a[i]==te[])
a1++;
else if (a[i]==te[])
a2++;
else if (a[i]==te[])
a3++;
else if (a[i]==te[])
a4++;
}
int f1=te[];
int f2=te[];
int f3=te[];
int f4=te[];
if (a4==)
{
printf("%d\n",f1+f2+f3);
return ;
}
if (a3==)
{
printf("%d\n",f1+f2+f4);
return ;
}
if (a2==)
{
printf("%d\n",f1+f3+f4);
return ;
}
if (a1==)
{
printf("%d\n",f2+f3+f4);
return ;
}
}
}
return ;
}
Codeforces Round #356 (Div. 2)A. Bear and Five Cards(简单模拟)的更多相关文章
- 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 ...
- 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 #356 (Div. 1) D. Bear and Chase 暴力
D. Bear and Chase 题目连接: http://codeforces.com/contest/679/problem/D Description Bearland has n citie ...
- Codeforces Round #356 (Div. 2) E. Bear and Square Grid 滑块
E. Bear and Square Grid 题目连接: http://www.codeforces.com/contest/680/problem/E Description You have a ...
- Codeforces Round #356 (Div. 2) D. Bear and Tower of Cubes dfs
D. Bear and Tower of Cubes 题目连接: http://www.codeforces.com/contest/680/problem/D Description Limak i ...
- 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. 1) C. Bear and Square Grid
C. Bear and Square Grid time limit per test 3 seconds memory limit per test 256 megabytes input stan ...
随机推荐
- Codeforces Round #339 Div.2 A - Link/Cut Tree
第一次正式参加常规赛想想有些小激动的呢 然后第一题就被hack了 心痛 _(:зゝ∠)_ tle点在于越界 因此结束循环条件从乘变为除 done //等等 这题没过总评 让我静静........ // ...
- HTML中特殊字符和与之对应的ASCII代码
ASCII代码是说明了在html中每个特殊字符的属性以及字符的简要说明.在使用html时,如何把ASCII代码添加到网页中.例如版权符号'©'在html中可以通过 "©"来显示. ...
- linux中的find命令——查找文件名
1.在某目录下查找名为“elm.cc”的文件 find /home/lijiajia/ -name elm.cc 2.查找文件名中包含某字符(如"elm")的文件 find /ho ...
- JVM 虚拟化
http://www.infoq.com/cn/news/2015/05/java20-multitenant-jvm http://2016.qconshanghai.com/presentatio ...
- jQuery-vsdoc.js文件是vs中的JavaScript intellisense,
在VS 2008中启用jQuery Intellisense的步骤 要在VS中启用jQuery的intellisense完成,你要遵循三个步骤: 第一步: 安装VS 2008 SP1 VS 2008 ...
- ISV 和SI 是什么
ISV是Independent Software Vendors 的英文缩写,意为"独立软件开发商",特指专门从事软件的开发.生产.销售和服务的企业,如微软(Microsoft). ...
- 递归函数练习:输出菲波拉契(Fibonacci)数列的前N项数据
/*====================================================================== 著名的菲波拉契(Fibonacci)数列,其第一项为0 ...
- js给定时器调用传递参数
给定时器调用传递参数 无论是window.setTimeout 还是window.setInterval,在使用函数名作为调用句柄时都不 能带参数,而在许多场合必需要带参数,这就需要想方法解决.例如对 ...
- 使用面向对象思想处理cookie
实例:使用面向对象思想处理cookie如果读者对cookie 不熟悉,可以在第七章学习它的使用方法,虽然在那里创建了几个通用函数用于cookie 的处理,但这些函数彼此分离,没有体现出是一个整体.联想 ...
- 解决JQuery中datatables设置隐藏显示列多次提交后台刷新数据的问题
此次项目开发过程中用到了Jquery的Datatables插件,无疑他是数据列表展示,解决MVC中同步过程中先走控制器后返回视图,查询数据过程中无法提示等待的弊端, 而且他所提供的各种方法也都有较强的 ...