博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Testing Round #12 B. Restaurant 贪心
阅读量:6293 次
发布时间:2019-06-22

本文共 3032 字,大约阅读时间需要 10 分钟。

B. Restaurant

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/597/problem/B

Description

A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li and the finish time ri (li ≤ ri).

Restaurant management can accept and reject orders. What is the maximal number of orders the restaurant can accept?
No two accepted orders can intersect, i.e. they can't share even a moment of time. If one order ends in the moment other starts, they can't be accepted both.

⋅2. Ignoring the buoys and relying on dogfighting to get point. If you and your opponent meet in the same position, you can try to fight with your opponent to score one point. For the proposal of game balance, two players are not allowed to fight before buoy #2 is touched by anybody.
There are three types of players.
Speeder: As a player specializing in high speed movement, he/she tries to avoid dogfighting while attempting to gain points by touching buoys.
Fighter: As a player specializing in dogfighting, he/she always tries to fight with the opponent to score points. Since a fighter is slower than a speeder, it's difficult for him/her to score points by touching buoys when the opponent is a speeder.
All-Rounder: A balanced player between Fighter and Speeder.
There will be a training match between Asuka (All-Rounder) and Shion (Speeder).
Since the match is only a training match, the rules are simplified: the game will end after the buoy #1 is touched by anybody. Shion is a speed lover, and his strategy is very simple: touch buoy #2,#3,#4,#1 along the shortest path.
Asuka is good at dogfighting, so she will always score one point by dogfighting with Shion, and the opponent will be stunned for T seconds after dogfighting. Since Asuka is slower than Shion, she decides to fight with Shion for only one time during the match. It is also assumed that if Asuka and Shion touch the buoy in the same time, the point will be given to Asuka and Asuka could also fight with Shion at the buoy. We assume that in such scenario, the dogfighting must happen after the buoy is touched by Asuka or Shion.
The speed of Asuka is V1 m/s. The speed of Shion is V2 m/s. Is there any possibility for Asuka to win the match (to have higher score)?

Input

The first line contains integer number n (1 ≤ n ≤ 5·105) — number of orders. The following n lines contain integer values li and ri each (1 ≤ li ≤ ri ≤ 109).

 

Output

Print the maximal number of orders that can be accepted.

Sample Input

6 4 8 1 5 4 7 2 5 1 3 6 8

Sample Output

2

HINT

 

题意

给你n个区间,然后让你选择尽量多的不同区间出来

让你输出数量

题解:

按照右坐标排序,然后贪心扫一遍就好了~

代码

 

#include
#include
#include
#include
using namespace std;#define maxn 500005struct node{ int l,r;};bool cmp(node a,node b){ if(a.r==b.r)return a.l
last) { ans++; last = p[i].r; } } printf("%d\n",ans);}

 

转载地址:http://omdta.baihongyu.com/

你可能感兴趣的文章
Python 元组
查看>>
hbase(ERROR: org.apache.hadoop.hbase.ipc.ServerNotRunningYetException: Server is not running yet)
查看>>
[ZJOI2010]count 数字计数
查看>>
多校4 1001 Olympiad
查看>>
hdu1085 Holding Bin-Laden Captive!
查看>>
hdu4811 Ball
查看>>
Docker实践--搭建Yapi测试平台
查看>>
align-content 与 align-items 区别
查看>>
a链接中,name属性的应用
查看>>
Java精选笔记_多线程(创建、生命周期及状态转换、调度、同步、通信)
查看>>
java Session统计在线用户,并且显示在线用户
查看>>
spring boot集成jpa(mysql)
查看>>
js实现的玫瑰花
查看>>
大话设计模式之责任链模式
查看>>
记录libreoffice实现office转pdf(适用于windows、linux)
查看>>
Python爬虫入门这一篇就够了
查看>>
彻底卸载Cygwin
查看>>
【转】安卓开发一个月之心得(广告平台篇)
查看>>
salt 批量部署与配置
查看>>
python使用cx_oracle模块连接oracle数据库
查看>>