题意:就是一个集合分开,有两种区分 对子:两个相同数字,顺子:连续三个不同数字,问最多分多少个

解法:贪心,如果当前数字不构成顺子就取对子 /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的更多相关文章

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

    Duizi and Shunzi Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  2. 2017ACM/ICPC广西邀请赛-重现赛

    HDU 6188 Duizi and Shunzi 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6188 思路: 签到题,以前写的. 实现代码: #inc ...

  3. 2017ACM/ICPC广西邀请赛

    A.A Math Problem #include <bits/stdc++.h> using namespace std; typedef long long ll; inline ll ...

  4. 2017ACM/ICPC广西邀请赛-重现赛(感谢广西大学)

    上一场CF打到心态爆炸,这几天也没啥想干的 A Math Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/3 ...

  5. 2017ACM/ICPC广西邀请赛-重现赛 1007.Duizi and Shunzi

    Problem Description Nike likes playing cards and makes a problem of it. Now give you n integers, ai( ...

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

  7. 2017ACM/ICPC广西邀请赛-重现赛 1004.Covering

    Problem Description Bob's school has a big playground, boys and girls always play games here after s ...

  8. HDU 6191 2017ACM/ICPC广西邀请赛 J Query on A Tree 可持久化01字典树+dfs序

    题意 给一颗\(n\)个节点的带点权的树,以\(1\)为根节点,\(q\)次询问,每次询问给出2个数\(u\),\(x\),求\(u\)的子树中的点上的值与\(x\)异或的值最大为多少 分析 先dfs ...

  9. 2017ACM/ICPC广西邀请赛-重现赛 1001 A Math Problem

    2017-08-31 16:48:00 writer:pprp 这个题比较容易,我用的是快速幂 写了一次就过了 题目如下: A Math Problem Time Limit: 2000/1000 M ...

随机推荐

  1. css3-rotate实现超炫环形旋转特效

    css3-rotate实现超炫环形旋转特效,css3特效,环形旋转,圆形旋转,css3-rotate实现超炫环形旋转特效是一款采用css3 rotate实现的蓝色环形旋转特效代码. http://ww ...

  2. PHP实现简单爬虫-抓取网页url

    <?php /** * 爬虫程序 -- 原型 * * 从给定的url获取html内容 * * @param string $url * @return string */ function _g ...

  3. Pycharm用鼠标滚轮控制字体大小的

    Pycharm用鼠标滚轮控制字体大小的   一.pycharm字体放大的设置 File —> setting —> Keymap —>在搜寻框中输入:increase —> I ...

  4. Linq 支持动态字查询集合, 也就是说根据传入的值进行查询。

    Linq 支持动态字查询集合, 也就是说根据传入的值进行查询. 比如我们有个类Patient, 其中有个字段PatientName, 现在有Patient集合, 想要查询PatientName为&qu ...

  5. java基础知识 学习 关于URL中传递的参数含有特殊字符

    有些符号在URL中是不能直接传递的,如果要在URL中传递这些特殊符号,那么就要使用他们的编码了.下表中列出了一些URL特殊符号及编码                                   ...

  6. docker 学习(七) docker 容器挂载

    1:docker的默认存放位置: $ sudo su # cd /var/lib/docker # ls -F containers/ graph/ repositories volumes/     ...

  7. 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)

    No valid host was found. There are not enough hosts available 'ascii' codec can't decode byte 0xe6 i ...

  8. zend studio 10.6.2破解和汉化

    破解文件下载地址 http://dldx.csdn.net/fd.php?i=881874911175745&s=b2f091d89f675e30c36dcc00c4cd2702   下载破解 ...

  9. <正则吃饺子> :关于微信支付的简单总结说明(二)

    关于微信退款 一.官方文档 申请退款:https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_4&index=6 二.退款流程 ...

  10. linux下gsoap的初次使用 -- c风格加法实例

    摘自: http://blog.csdn.net/jinpw/article/details/3346844 https://www.cnblogs.com/dkblog/archive/2011/0 ...