#include<bits/stdc++.h>
using namespace std;
int a[100007],f[100007],ans,n;
int main(){
cin>>n;
for(int i=n;i>=1;--i)
scanf("%d",&a[i]);
for(int i=1;i<=n;++i)//逆向遍历
if(f[ans]<=a[i])//如果f数组里比较小,把a数组放进f数组,让大的放在ans位置上
f[++ans]=a[i];
else
f[upper_bound(f+1,f+1+ans,a[i])-f]=a[i];//f数组比较大,把它变成a数组的数,继续向前找更小的,使得这一串只要染色一次
cout<<ans;//ans就是f数组里的数字个数,代表有一些小的数字在后面没有办法找到前面更小的数字使得一齐染色
return 0;
}

Atcoder Beginning Contest 134E(二分查找(upper_bound),思维)的更多相关文章

  1. AtCoder Beginner Contest 134-E - Sequence Decomposing

    (https://atcoder.jp/contests/abc134/tasks/abc134_e) 题意:找出最小个数的最长上升子序列 思路:找出最长上升子序列的最小个数,只需要找出每个最小上升子 ...

  2. Atcoder Beginner Contest 140E(多重集,思维)

    #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;multiset<long long&g ...

  3. cf1216E2 Numerical Sequence (hard version) 二分查找、思维题

    题目描述 The only difference between the easy and the hard versions is the maximum value of k. You are g ...

  4. AtCoder Beginner Contest 124 D - Handstand(思维+前缀和)

    D - Handstand Time Limit: 2 sec / Memory Limit: 1024 MB Score : 400400 points Problem Statement NN p ...

  5. Atcoder Grand Contest 031B(DP,思维)

    #include<bits/stdc++.h>using namespace std;int a[200007];int b[200007];long long dp[200007];lo ...

  6. Atcoder Beginner Contest 139E(模拟,思维)

    #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;int n;int a[1007][1007] ...

  7. Atcoder Grand Contest 037A(贪心,思维)

    #include<bits/stdc++.h>using namespace std;string s;char ans[200007][7];char anss[200007][7];i ...

  8. AtCoder Beginner Contest 188 D - Snuke Prime (思维,差分)

    题意:你需要订阅一些服务,每个服务每天需要花费\(c_i\),要从第\(a_i\)用到第\(b_i\)天,你可以购买会员,会员每天需要花费\(C\),但是这天的服务不用再另花钱了,问你订阅这些服务的最 ...

  9. AtCoder Beginner Contest 173 E - Multiplication 4 (思维)

    题意:有\(n\)个数,从中选\(k\)个数累乘,求最大的乘积\((mod\ 10^9+7)\). 题解: 1.假如全是负数,并且选奇数个,那么从小到大选. 2.否则,考虑当前状态,假如\(k\)是奇 ...

随机推荐

  1. linux sftp 和scp 运用

    Linux scp命令: Upload  to remote :复制本地文件到远程 Part1: Scp  -P port  local_file  remote_user@remote_ip:rem ...

  2. Python学习之函数篇

    python查看对象,函数帮助文档:.__doc__,例:str.split.__doc__ 查看详细对象,函数文档:help(),例:help(str.split) 函数参数可设置默认值 如果不能提 ...

  3. console.log 如何打印对象

    问题描述: var obj={a:1,b:2}; console.log(obj); 控制台返回的值是object. 解决方案: console.log(JSON.stringify(obj))

  4. 安卓开发:Android Studio自动import

    我只想说,真好用!哈哈,提高效率的好东西. 参考: [https://blog.csdn.net/pjdd123/article/details/80953669] [https://www.cnbl ...

  5. [转]Ethereum-智能合约最佳实践

    主要章节如下: Solidity安全贴士 已知的攻击手段 竞态 可重入 交易顺序依赖 针对Gas的攻击 上溢/下溢 工程技术 参考文献 这篇文档旨在为Solidity开发人员提供一些智能合约的secu ...

  6. caffe 模型的加载

    在caffe中模型的加载是通过这个函数加载的: void Net<Dtype>::CopyTrainedLayersFrom(const string trained_filename)

  7. Spring的事务实现原理

    主流程 Spring的事务采用AOP的方式实现. @Transactional 注解的属性信息 name                当在配置文件中有多个 TransactionManager , ...

  8. 剑指offer系列——62.二叉搜索树的第k个结点

    Q:给定一棵二叉搜索树,请找出其中的第k小的结点.例如, (5,3,7,2,4,6,8) 中,按结点数值大小顺序第三小结点的值为4. T: 中序遍历,递归: int count = 0; public ...

  9. markdown区块

    Markdown 区块 Markdown 区块引用是在段落开头使用 > 符号 ,然后后面紧跟一个空格符号: > 区块引用 > 菜鸟教程 > 学的不仅是技术更是梦想 显示结果如下 ...

  10. 【Android】数据存储和访问

    一.SharedPreferences 2.SQLite