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 ...
随机推荐
- 利用jsp技术实现用户注册
利用jsp技术实现用户注册,包含register.html和register_check.jsp页面代码1. [代码]J2EE实验 <!DOCTYPE html PUBLIC " ...
- jsp参数传递
jsp参数传递 jsp中四种传递参数的方法 1.form表单 2.request.setAttribute();和request.getAttribute(); 3.超链接:<a herf=&q ...
- 淘宝双十一页面(Flexible)
以下demo点我下载 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...
- IE滚动条
之前一直没留意过IE下面的滚动条样式,今天碰到一个优化需求,需要去掉横向的滚动条,只保留竖的滚动条. 实现方式很简单,设置宽度,overflow-x:hiddle:overflow-y:scroll ...
- SVN版本控制详解
1 版本控制 1.1 如果没有版本控制? Team开发必备. 一个人开发(必备). 版本控制:控制(代码)版本. 论文:版本控制? 毕业论文-4-22.doc 毕业论文-5-01.doc 毕业论文-f ...
- BZOJ2006:[NOI2010]超级钢琴
浅谈\(RMQ\):https://www.cnblogs.com/AKMer/p/10128219.html 题目传送门:https://www.lydsy.com/JudgeOnline/prob ...
- Vmware ESXi 6.5 安装手册
1 安装前准备 1.1 硬件环境准备 无 备注: 本指导书以虚拟光驱.虚拟软驱为例,如使用物理光驱.物理软驱安装系统操作则以实际系统光盘.软盘代替. 1.2 ...
- Oracle字段增删改方法总结
一.修改字段的语法:alter table tablename modify (字段名 类型 [default value][null/not null],….);有一个表名为tb,字段段名为name ...
- 数论 最简分数 Farey序列求最简分数+POJ3374
法雷数列 定义和定理 定义一: 最简分数(也称既约分数或不可约分数).若p,q的最大公约数是1,我们称分数p/q是最简分数. 定义二: 真分数,若p,q是正整数,0<p/q<1, 我们说p ...
- UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)
2017-03-16 11:23:29.601 1238 ERROR nova.compute.manager [instance: 3f195047-250a-4eb5-8da0-63bea6e26 ...