当前位置:网站首页>【集训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;
}
边栏推荐
- 6-19 vulnerability exploitation -nsf to obtain the target password file
- Why are test / development programmers who are better paid than me? Abandoned by the times
- 大家下午好,请教一个问题:如何从保存点启动一个之前以SQL提交的作业?问题描述:用SQL在cl
- 国际大咖 VS 本土开源新星 | ApacheCon Asia 主题演讲议程全览
- JS closure simulates private variable interview questions and immediately executes function Iife
- Avalanche subnets vs. polygon supernets of application chain
- SQL中去去重的三种方式
- 解决哈希冲突的几种方式
- 重磅公布!ICML2022奖项:15篇杰出论文,复旦、厦大、上交大研究入选
- Kudu design tablet
猜你喜欢

JS 递归 斐波那契数列 深克隆

Tree DP problem

硬件开发与市场产业

Establishment of Eureka registration center Eureka server

(25) top level menu of blender source code analysis blender menu

Ascend target detection and recognition - customize your own AI application

性能调优bug层出不穷?这3份文档轻松搞定JVM调优

天翼云Web应用防火墙(边缘云版)支持检测和拦截Apache Spark shell命令注入漏洞

About the adjustment of the game background, reading this article is enough

Spark统一内存划分
随机推荐
Hardware development and market industry
ASEMI整流桥KBPC2510,KBPC2510参数,KBPC2510规格书
2019 popularization group summary
API analysis of Taobao / tmall shipping address list and express delivery fees
Advantages of time series database and traditional database
Week 16 OJ practice 1 calculates the day of the year
Environment setup mongodb
环境搭建-MongoDB
Is it safe to open an account online now? Who do you want to open a stock account?
Eureka Registry - from entry to application
Linear regression from zero sum using mxnet
第16周OJ实践1 计算该日在本年中是第几天
Open source kaggle cat and dog data set -- used in classic CNN classification practice
办公软件常用快捷键大全
重磅公布!ICML2022奖项:15篇杰出论文,复旦、厦大、上交大研究入选
国际大咖 VS 本土开源新星 | ApacheCon Asia 主题演讲议程全览
一文详解吞吐量、QPS、TPS、并发数等高并发指标
[virtual machine data recovery] data recovery cases in which XenServer virtual machine is unavailable due to accidental power failure and virtual disk files are lost
Pay attention to the traffic safety warning of tourism passenger transport issued by the Ministry of public security
Detailed explanation of openwrt's feeds.conf.default