当前位置:网站首页>[51nod p3111] xiaoming'ai intercepts [Las]
[51nod p3111] xiaoming'ai intercepts [Las]
2022-06-13 09:35:00 【Ayane.】
analysis :
See the data range n l o g n nlogn nlogn Find the longest non ascending subsequence
It's just u p p e r _ b o u n d upper\_bound upper_bound Followed by g r e a t e r greater greater You can find the first position less than
Of course Tree array do n l o g n nlogn nlogn
CODE:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define reg register
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,a[N],f[N],ans;
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
f[++ans]=a[1];
for(int i=2;i<=n;i++)
{
if(a[i]<=f[ans]) f[++ans]=a[i];
else
{
int p=upper_bound(f+1,f+ans+1,a[i],greater<int>())-f;
f[p]=a[i];
}
}
printf("%d",ans);
return 0;
}
边栏推荐
- LeetCode 6098. Count the number of subarrays whose score is less than K (prefix and + binary search)
- I set up a blog
- LeetCode 5270. 网格中的最小路径代价(动态规划)
- LeetCode 343. integer partition
- @Value不生效及extend/implement其他类无法注入bean的手动注入
- Trees and binary trees: the concept of binary trees
- C#入门系列(十三) -- 初识结构体
- VDD,DVDD,AVDD,VCC,AFVDD,DOVDD,IOVDD
- Cisco, Huawei network equipment
- 拜登:希望尽快签署两党枪支安全改革法案
猜你喜欢

acwing 789. Range of numbers (dichotomy + suitable for understanding dichotomy boundary)
![1-2 24:00 (20 points) [CSP certification true question]](/img/3b/fe2c0e46dca604e5906d9c5ceabbe3.jpg)
1-2 24:00 (20 points) [CSP certification true question]

Acwing785. quick sort (sort+ quick sort + merge sort)

VGA common resolution and calculation method

Online debugging tool Arthas advanced

Dynamic display of analog clock using digital clock in turtle Library

C language: file operation

Jenkins接入Openldap用戶認證

BGP 联邦+Community

Tree and binary tree: basic operation and implementation of binary tree
随机推荐
LeetCode 202. 快乐数
turtle库显示系统时间
1-2 24:00 (20 points) [CSP certification true question]
1-4 message passing interface [CSP authentication]
Classes and objects -- encapsulation
Jenkins accédant à l'authentification de l'utilisateur openldap
acwing 789. Range of numbers (dichotomy + suitable for understanding dichotomy boundary)
LeetCode 5289. Fair distribution of cookies (DFS)
acwing 786. Number k
全新BMW i3的操控,能符合对3系之名产品的期待吗?
Instruction level parallelism (?)
Online debugging tool Arthas Foundation
Classes and objects -- Inheritance
静态变量与一个类相关联,只要该类在内存中(只要您的应用程序终止,该变量就不存在)就可以使用。(堆本体,栈引用)
JS【中高级】部分的知识点我帮你们总结好了
LeetCode 剑指 Offer 30. 包含min函数的栈
C language: summary of question brushing (1)
Jenkins integrates LDAP. The problem of login failure of Jenkins users caused by LDAP configuration error is solved
turtle库的使用数字时钟模拟时钟动态显示
LeetCode 6097. 替换字符后匹配(字典)

