hdu-1050(贪心+模拟)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050
思路:由图可知,1对应2,3对应4,以此类推,如果x,y是偶数则变为奇数;
每次输入两个区间,找区间重合几次,重合的部分最多的就是最终移动几次。
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int vc[];
int main(void)
{
int x,y,n,t,i,mx;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
memset(vc,,sizeof(vc));
mx=;
while(n--)
{
scanf("%d %d",&x,&y);
if(x%==) x--;
if(y%==) y--;
if(x>y) swap(x,y);
for(i=x;i<=y;i++) vc[i]++,mx=vc[i]>mx?vc[i]:mx;
}
printf("%d\n",mx*);
}
return ;
}
hdu-1050(贪心+模拟)的更多相关文章
- HDU 1528 贪心模拟/二分图
Card Game Cheater Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- hdu 6034 贪心模拟 好坑
关键在排序!!! 数组间的排序会超时,所以需要把一个数组映射成一个数字,就可以了 #include <bits/stdc++.h> using namespace std; typedef ...
- hdu 4974 贪心
http://acm.hdu.edu.cn/showproblem.php?pid=4974 n个人进行选秀,有一个人做裁判,每次有两人进行对决,裁判可以选择为两人打分,可以同时加上1分,或者单独为一 ...
- 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...
- 贪心+模拟 ZOJ 3829 Known Notation
题目传送门 /* 题意:一串字符串,问要最少操作数使得成为合法的后缀表达式 贪心+模拟:数字个数 >= *个数+1 所以若数字少了先补上在前面,然后把不合法的*和最后的数字交换,记录次数 岛娘的 ...
- CodeForces ---596B--Wilbur and Array(贪心模拟)
Wilbur and Array Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Su ...
- --hdu 1050 Moving Tables(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050 AC code: #include<stdio.h> #include<str ...
- hdu 4023 2011上海赛区网络赛C 贪心+模拟
以为是贪心,结果不是,2333 贪心最后对自己绝对有利的情况 点我 #include<cstdio> #include<iostream> #include<algori ...
- HDU 4023 (博弈 贪心 模拟) Game
如果硬要说这算是博弈题目的话,那这个博弈是不公平博弈(partizan games),因为双方面对同一个局面做出来的决策是不一样的. 我们平时做的博弈都是公平博弈(impartial games),所 ...
- HDU 1050 Moving Tables (贪心)
题意:在一个走廊两边都有对称分布的连续房间,现在有n张桌子需要从a移动到b房间.每次移动需要10分钟, 但是如果两次移动中需要经过相同的走廊位置,则不能同时进行,需要分开移动.最后求最少需要多长时间移 ...
随机推荐
- XE4 TStringDynArray 比 c6 的TStringList 好用 字符串 分解 分割 转换 TByteDynArray
TStringDynArray 动态数组 字符串 分解 分割 System::DynamicArray<System::UnicodeString> TByteDynArray, ...
- License 校验
1:了解keytool 的一些命令 http://www.micmiu.com/lang/java/keytool-start-guide/ 本人在github找的一个demo:https://gi ...
- jstatd - Virtual Machine jstat Daemon
jstatd [options] 参数:options 命令行参数,可以按任何顺序,但如果有多余的或者中有互斥的参数,最后制定的那个参数将有优先权 options: -nr 当一个存在的RMI Reg ...
- Haskell语言学习笔记(65)Data.HashMap
安装 unordered-containers $ cabal install unordered-containers Installed unordered-containers-0.2.9.0 ...
- 【340】GIS related knowledge
mpk: 对地图文档以及所有引用的数据源进行打包可创建经过压缩的单个 .mpk 文件.参考,可以通过 Package Map 工具实现. Collector for ArcGIS Survey123 ...
- scala -- 传名参数
object Test{ def main(args: Array[String]): Unit = { def test(code : => Unit){// 传名参数 不计算函数值,而是把函 ...
- js 获取input选择的图片的信息
1JS $("#btn").click(function () { var imageEle = document.getElementById("images" ...
- linux 常用find
磁盘查找文件内容: find .|xargs grep x find . -exec grep x{} \; 磁盘查找文件名称: find / -name "httpd.conf" ...
- springboot引入springSecurity无法post提交表单
参考https://blog.csdn.net/shawearn1027/article/details/71119587 表单中添加<input type="hidden" ...
- 10.9zuoye
public class fulei { public fulei() { System.out.println("欢迎使用海尔"); } public String Pinpai ...