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 ...
随机推荐
- apache开启url rewrite模块
在把服务器数据转移到本地服务器之后,本地打开首页出现排版紊乱等问题,经过大神指点说是url rewrite的问题. 本篇文章主要写怎样开启apache的url rewrite功能. 打开Apache2 ...
- Oracle学习系列3
Oracle学习系列3 ************************************************************************************ 多表查 ...
- URL 正则表达式
(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])? From h ...
- qt 获取当前主机的信息
随着科技的发展,嵌入式技术在生活中越来越扮演者重要的角色,小到智能手环.手机,大到智能家居.汽车,都和嵌入式技术息息相关.在嵌入式系统中,拥有良好的用户界面会使产品更具市场优势.最近正好有机会用qt做 ...
- kuangbin_ShortPath J (POJ 1511)
其实虽然一开始有被这个题的8000MS 和 256MB限制又被吓到 但是严格来说跟之前的POJ 3268是一样的做法只是数据大了点 但是问题就出在数据大了点上 其实严格来说也不大 1e6 数组加起来大 ...
- caffe: compile error : undefined reference to `cv::imread(cv::String const&, int)' et al.
when I compile caffe file : .build_debug/lib/libcaffe.so: undefined reference to `cv::imread(cv::Str ...
- 【Unity3D技巧】一个简单的Unity-UI框架的实现
如何使用 请直接导入UnityUIFramework这个UnityPackage,然后进入名为Test的Scene即可开始体验各种特性,Enjoy!你可以通过访问我的Github进行查阅和下载. Vi ...
- linux概念之IPC
一切皆文件,文件类型为普通,目录,管道,socket,链接,块设备,字符设备cd /proc/2305/fd/ 该进程打开了6个文件描述符,三个为字符设备即012,三个为socket即345,sock ...
- C#, float.ToString()的一个坑
下面代码的输出竟然是2.0: float a=1.95f;Debug.Log(a.ToString("0.0")); 如果想截取一位小数,可以: float a=1.95f; fl ...
- TaffyDB:开源JavaScript数据库
你是否曾经注意到javascript的对象有点像数据库中的记录,你把很多javascript对象包装到一起时就像是你在处理一个数据库中的表,TaffyDB是一个Javascript库,它提供了强大的数 ...