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

解法:贪心,如果当前数字不构成顺子就取对子 /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左右滑动开关按钮

    纯CSS3特效左右滑动开关按钮是一款非常酷的CSS3 3D开关按钮,点击按钮可以左右滑动,就像开关打开闭合一样的效果. http://www.huiyi8.com/sc/10626.html

  2. 分享知识-快乐自己:SpringMvc中 页面日期格式到后台的类型转换

    日期格式的类型转换: 以往在 from 表单提交的时候,都会有字符串.数字.还有时间格式等信息. 往往如果是数字提交的话底层会自动帮我们把类型进行了隐式转换. 但是日期格式的却不能自动转换,这就需要我 ...

  3. 一些flag

    连续两道组合计数题 WA 在杨辉三角上,TM 我要是联赛杨辉三角萎了就剁*. 又连续两道题萎在数组越界上,TM 我要是联赛数组越界就吃*.

  4. codeforces 569A A. Music(水题)

    题目链接: A. Music time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  5. ZJOI2012题解

    t1灾难 给一个食物网 如果一个生物吃的所有东西都灭绝了 它也跟着灭绝 求每个生物灭绝时跟着灭绝的生物数量 支配树裸题,我们先拓扑排序,然后建立一棵树满足一个点灭绝时,有且仅有它的子树跟着灭绝 考虑如 ...

  6. 关于Socket 多线程 的一篇好文章

    http://www.kegel.com/c10k.html#topIt's time for web servers to handle ten thousand clients simultane ...

  7. Virtualenwrapper

    1. Introduction Virtualenvwrapper is a set of extensions to Ian Bicking's virtualenv tool. The exten ...

  8. JSP环境探针-当前电脑所有系统参数

    1 <%@ page contentType="text/html;charset=gb2312" %> <%@ page import="java.u ...

  9. C#闪动任务栏的方法

    用FlashWindowEx可以实现窗口的闪烁,结构如下: /// <summary> /// 闪烁窗口 /// </summary> /// <param name=& ...

  10. php学习笔记-PHP中的几个取整函数

    floor是向下取整,比如4.5,它是在4和5之间的一个数,那么结果就是4. ceil是向上取整,比如3.7,它是在3和4之间的一个数,那么结果就是4. round是对一个数四舍五入,小数部分如果小于 ...