当前位置:网站首页>【集训Day3】section
【集训Day3】section
2022-07-26 16:55:00 【SSL_GYX】
section

解题思路
先将左端点排序,对右端点做最长不下降子序列。
code
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
int n;
int b[100010],tot;
struct abc{
int x,y;
}a[100010];
int cmp(abc a,abc b)
{
if(a.x!=b.x)
return a.x<b.x;
return a.y>b.y;
}
int fd(int x)
{
int l=1,r=tot,s;
while(l<=r)
{
int mid=(l+r)/2;
if(b[mid]<x)
r=mid-1,s=mid;
else
l=mid+1;
}
return s;
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
scanf("%d%d",&a[i].x,&a[i].y);
sort(a+1,a+n+1,cmp);
b[++tot]=a[1].y;
for(int i=2;i<=n;i++)
{
if(a[i].y<=b[tot])
b[++tot]=a[i].y;
else
b[fd(a[i].y)]=a[i].y;
}
cout<<tot<<endl;
}
边栏推荐
- VIM visualization mode and its usage
- 点击劫持攻击
- Leetcode:1206. design jump table [jump table board]
- [300 opencv routines] 240. Shi Tomas corner detection in opencv
- 重磅!《2022中国开源发展蓝皮书》正式发布
- Kudu design tablet
- 云渲染-体积云【理论基础与实现方案】
- Pytest (mind map)
- 第17周自由入侵 指针练习--输出最大值
- Oracle is slow to perform a large number of DML operations. Is it the problem of CPU or hard disk?
猜你喜欢

敏捷开发与DevOps的对比

The diagram of user login verification process is well written!

What kind of product is the Jetson nano? (how about the performance of Jetson nano)

Just this time! Talk about the technical solutions of distributed system in detail

# MySQL 七种连接方式图解

国际大咖 VS 本土开源新星 | ApacheCon Asia 主题演讲议程全览

CCS tm4c123 new project

Asemi rectifier bridge kbpc2510, kbpc2510 parameters, kbpc2510 specifications

Application of machine vision in service robot

Establishment of Eureka registration center Eureka server
随机推荐
OpenWrt之feeds.conf.default详解
使用 replace-regexp 在行首添加序号
Summer Challenge openharmony greedy snake based on JS
2019普及组总结
就这一次!详细聊聊分布式系统的那些技术方案
Asemi rectifier bridge kbpc3510, kbpc3510 package, kbpc3510 application
【元宇宙欧米说】剖析 Web3 风险挑战,构筑 Web3 生态安全
[cloud native kubernetes actual combat] kubeopertor installation tutorial
Machine learning - what are machine learning, supervised learning, and unsupervised learning
如何快速使用 ELisp 进行插件编写
Implement softmax classification from zero sum using mxnet
徽商期货网上开户安全吗?开户办理流程是怎样的?
Gan (generative adversarial network, GaN) generative countermeasure network
JS recursive Fibonacci sequence deep cloning
Common super easy to use regular expressions!
The user experience center of Analysys Qianfan bank was established to help upgrade the user experience of the banking industry
How to write plug-ins quickly with elisp
Definition of graph traversal and depth first search and breadth first search (I)
# MySQL 七种连接方式图解
Week 16 OJ practice 1 calculates the day of the year