2017ACM/ICPC广西邀请赛 Duizi and Shunzi


题意:就是一个集合分开,有两种区分 对子:两个相同数字,顺子:连续三个不同数字,问最多分多少个
解法:贪心,如果当前数字不构成顺子就取对子 /2,如果可以取顺子,那么先取顺子再取对子
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string.h>
#include <map>
using namespace std;
struct Node{
int x,y;
}node[];
map<int,int>Mp;
int n;
map<int,int>::iterator it;
int main(){
while(~scanf("%d",&n)){
Mp.clear();
int num;
int sum=;
for(int i=;i<n;i++){
scanf("%d",&num);
Mp[num]++;
}
int cnt=;
for(int i=;i<=n;i++){
int ans=i-;
int cos=i-;
if(Mp[ans]&&Mp[cos]&&Mp[i]){
while(Mp[ans]&&Mp[cos]&&Mp[i]){
//cout<<ans<<" "<<cos<<" "<<i<<endl;
Mp[ans]--;
Mp[cos]--;
Mp[i]--;
cnt++;
}
cnt+=Mp[i]/;
Mp[i]%=;
}else{
cnt+=Mp[i]/;
Mp[i]%=;
}
}
printf("%d\n",cnt);
}
return ;
}
2017ACM/ICPC广西邀请赛 Duizi and Shunzi的更多相关文章
- 2017ACM/ICPC广西邀请赛 1007 Duizi and Shunzi
Duizi and Shunzi Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 2017ACM/ICPC广西邀请赛-重现赛
HDU 6188 Duizi and Shunzi 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6188 思路: 签到题,以前写的. 实现代码: #inc ...
- 2017ACM/ICPC广西邀请赛
A.A Math Problem #include <bits/stdc++.h> using namespace std; typedef long long ll; inline ll ...
- 2017ACM/ICPC广西邀请赛-重现赛(感谢广西大学)
上一场CF打到心态爆炸,这几天也没啥想干的 A Math Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/3 ...
- 2017ACM/ICPC广西邀请赛-重现赛 1007.Duizi and Shunzi
Problem Description Nike likes playing cards and makes a problem of it. Now give you n integers, ai( ...
- 2017ACM/ICPC广西邀请赛-重现赛 1010.Query on A Tree
Problem Description Monkey A lives on a tree, he always plays on this tree. One day, monkey A learne ...
- 2017ACM/ICPC广西邀请赛-重现赛 1004.Covering
Problem Description Bob's school has a big playground, boys and girls always play games here after s ...
- HDU 6191 2017ACM/ICPC广西邀请赛 J Query on A Tree 可持久化01字典树+dfs序
题意 给一颗\(n\)个节点的带点权的树,以\(1\)为根节点,\(q\)次询问,每次询问给出2个数\(u\),\(x\),求\(u\)的子树中的点上的值与\(x\)异或的值最大为多少 分析 先dfs ...
- 2017ACM/ICPC广西邀请赛-重现赛 1001 A Math Problem
2017-08-31 16:48:00 writer:pprp 这个题比较容易,我用的是快速幂 写了一次就过了 题目如下: A Math Problem Time Limit: 2000/1000 M ...
随机推荐
- tensorflow knn 预测房价 注意有 Min-Max Scaling
示例数据: 0.00632 18.00 2.310 0 0.5380 6.5750 65.20 4.0900 1 296.0 15.30 396.90 4.98 24.00 0.02731 0.00 ...
- Memcached HA架构探索
https://code.google.com/p/memagent/ 标签:memcached magent 高可用 HA 架构原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者 ...
- L85
Surgical Never Events Happen Nevertheless Surgeons call them "never events", because they ...
- storm--chuanzhiboke
Storm里面有7种类型的stream grouping 1. Shuffle Grouping: 随机分组, 随机派发stream里面的tuple,保证每个bolt接收到的tuple数目大致相同. ...
- 每天一个linux命令(5):mkdir命令
版权声明更新:2017-05-09博主:LuckyAlan联系:liuwenvip163@163.com声明:吃水不忘挖井人,转载请注明出处! 1 文章介绍 本文介绍了Linux下命令mkdir. 2 ...
- iOS 自定义UINavigationController返回按钮
主要代码如下: //自定义导航栏返回按钮 self.navigationItem.leftBarButtonItem = ({ //导航栏返回背景视图 UIView *view = [[UIView ...
- Swift范性
关于泛型 「泛型」(Generic Code)也许是Swift相对于OC的最大特性之一吧!基于Swift的「泛型」特性,你能够写出扩展性更强.复用性更强的方法.类型,它可以让你尽可能避免重复代码,用一 ...
- 设置可见GPU方式
只可见第一块GPU os.environ["CUDA_VISIBLE_DEVICES"] = "0"
- hive通过spark导入hbase
发现采用shcjar的话,总是执行到某个点就停止了 于是我打算尝试一下直接说哦用org.apache.hadoop.hbase.spark这个datasource看看 确实不行,即使没有createt ...
- linux控制USB的绑定/解绑
linux控制USB的绑定/解绑 http://www.jianshu.com/p/57293f9be558 今天工作中遇到一个问题, 要用代码实现USB的enable和disable. 谷歌了一番, ...