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. Xcode7如何进行真机测试

    1. 下载xcode7 可以通过访问 https://developer.apple.com/xcode/downloads/ 下载最新的xcode7的版本 2. 配置accounts 打开xcode ...

  2. Sublime Text3快捷方式与使用技巧

    Sublime Text 3 快捷键精华版 Ctrl+Shift+P:  打开命令面板Ctrl+P:  搜索项目中的文件Ctrl+G: 跳转到第几行Ctrl+W: 关闭当前打开文件Ctrl+Shift ...

  3. java的nio之:java的nio系列教程之DatagramChannel

    Java NIO中的DatagramChannel是一个能收发UDP包的通道.因为UDP是无连接的网络协议,所以不能像其它通道那样读取和写入.它发送和接收的是数据包. 打开 DatagramChann ...

  4. perform-two-phase-commits/

    https://docs.mongodb.com/manual/tutorial/perform-two-phase-commits/

  5. Unity3D研究院之Android同步方法读取streamingAssets

    版本Unity5.3.3 Android 小米pad1 首先非常感谢 @守着阳光 同学在下面的留言.让我解决了一个大的谜团.. 开始我知道 StreamingAssets 路径是这个 path = & ...

  6. 利用KMeans聚类进行航空公司客户价值分析

    准确的客户分类的结果是企业优化营销资源的重要依据,本文利用了航空公司的部分数据,利用Kmeans聚类方法,对航空公司的客户进行了分类,来识别出不同的客户群体,从来发现有用的客户,从而对不同价值的客户类 ...

  7. DbContextConfiguration 属性

    属性 AutoDetectChangesEnabled 获取或设置一个值,该值指示是否通过 DbContext 和相关类的方法自动调用 DetectChanges 方法. 默认值为 true. Ens ...

  8. Apache Kafka 分布式消息队列中间件安装与配置 转载

    bin/zkServer.sh start /home/guym/down/kafka_2.8.0-0.8.0/config/zookeeper.properties& bin/kafka-s ...

  9. hadoop(四): 本地 hbase 集群配置 Azure Blob Storage

    基于 HDP2.4安装(五):集群及组件安装 创建的hadoop集群,修改默认配置,将hbase 存储配置为 Azure Blob Storage 目录: 简述 配置 验证 FAQ 简述: hadoo ...

  10. js 自己创建ready多个可以依次加载

    js会把相同的方法名给覆盖了,很多时候我们都无法再页面加载的时候写多个onload事件,这样只有最后一个才能起效,所以从网上找了找,最后决定自己写一个,例子很简单,希望有高人来指导指导 <!DO ...