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

解法:贪心,如果当前数字不构成顺子就取对子 /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. julia

    版本还不成熟,等成熟了再完整的看看吧.

  2. C语言的内存四区模型和函数调用模型

    首先是操作系统将代码程序加载到内存中 然后将内存分为4个区 栈区,程序的局部变量区,函数传递的参数,由编译器自动进行内存资源的释放. 堆区,动态内存申请,如果不手动释放内存,则这块内存不会进行析构. ...

  3. android自定义控件(一) 官方文档的翻译

    构建自定义组件 Android中,你的应用程序程序与View类组件有着一种固定的联系,例如按钮(Button).文本框(TextView),可编辑文本框(EditText),列表框(ListView) ...

  4. Sox语音转换的相关知识

    SoX-linux 里操作音频的瑞士军刀 Sox是最为著名的Open Source声音文件 格式转换工具.已经被广泛移植到Dos.windows.OS2.Sun.Next.Unix.Linux等多个操 ...

  5. noip2013提高组:积木大赛

    题目描述 春春幼儿园举办了一年一度的“积木大赛”.今年比赛的内容是搭建一座宽度为n的大厦,大厦可以看成由n块宽度为1的积木组成,第n块积木的最终高度需要是hi. 在搭建开始之前,没有任何积木(可以看成 ...

  6. POJ3159(最短路)

    Candies Time Limit: 1500MS   Memory Limit: 131072K Total Submissions: 27051   Accepted: 7454 Descrip ...

  7. DCloud-HTML5+:5+ App开发入门指南

    ylbtech-DCloud-HTML5+:5+ App开发入门指南 1.返回顶部 1. 5+ App开发入门指南 App App入门 HTML5 Plus应用概述 HTML5 Plus移动App,简 ...

  8. 'xxx' declared `static' but never defined

    'xxx' declared `static' but never defined [问题描述] uart.c文件中有函数read_sample的实现: [plain] view plain copy ...

  9. RedisDesktopManager 可视化工具提示:无法加载键:Scan..

    原因是redis的版本过低,window下的redis-cli.exe客户端输入 info 命令可看到该redis的版本,这个scan查看要redis2.80版本以上!!!!

  10. js操作Iframe非当前最上层窗体

    如果当前窗口不是最上层窗口(比如是在Iframe中),那么就把自己变为最上层窗口.  <script language="javascript" type="tex ...