A. Bear and Five Cards
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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?

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.

Examples
input
7 3 7 3 20
output
26
input
7 9 3 1 8
output
28
input
10 10 10 10 10
output
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(简单模拟)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. ipconfig /flushdns 解释

    当我们一域名的形式访问过目标网站后,该网站的域名和IP地址对应关系就会自动保存到本地工作站的DNS缓存列表中,如果以后再次访问该域名,浏览器就会先访问DNS缓存列表中的信息.但是,如果被访问网站的域名 ...

  2. [luogu P2170] 选学霸(并查集+dp)

    题目传送门:https://www.luogu.org/problem/show?pid=2170 题目描述 老师想从N名学生中选M人当学霸,但有K对人实力相当,如果实力相当的人中,一部分被选上,另一 ...

  3. 深入理解html5系列-文本标签

    转:http://blog.csdn.net/lihui130135/article/details/45150501 文章简介:       关于html5相信大家早已经耳熟能详,但是他真正的意义在 ...

  4. 【NOIP2007】矩阵取数

    因为傻逼写错高精度搞了一下午浪费好多时间,好想哭qaq 原题: 帅帅经常更同学玩一个矩阵取数游戏:对于一个给定的n*m的矩阵,矩阵中的每个元素aij据为非负整数.游戏规则如下: 1. 每次取数时须从每 ...

  5. kuangbin_ShortPath E (POJ 1860)

    第一次做判环 然后RE了五次 死在了奇怪的点 memset(vis, 0, sizeof dis); memset(dis, 0, sizeof vis); 什么鬼?? 什么鬼?? 其实代码本身还是不 ...

  6. java 读取文件的字节数组

    /*文件64位编码*/ public static void main(String[] args) {    byte[] fileByte = toByteArray(newFile);   St ...

  7. HTTPS-HSTS协议(强制客户端使用HTTPS与服务器创建连接)

    HSTS(HTTP Strict Transport Security)国际互联网工程组织IETE正在推行一种新的Web安全协议 HSTS的作用是强制客户端(如浏览器)使用HTTPS与服务器创建连接. ...

  8. QQ登入(3)QQ空间分享-无需登入

    public void myclick2(View v){ //QZone分享, SHARE_TO_QQ_TYPE_DEFAULT 图文,SHARE_TO_QQ_TYPE_IMAGE 纯图 ,SHAR ...

  9. Understanding virtualxid && transactionid

    对pg_locks视图中的virtualxid和transactionid字段感到困惑,经查阅资料,特此在此整理一下学习内容: pg_locks Columns Name Type Reference ...

  10. vb6中webbrowser控件树转换备忘

    Dim doc As HTMLDocument Set doc = WebBrowser1.Document Dim inputs As IHTMLElementCollection Set inpu ...