luogu1020 导弹拦截
来源:互联网 发布:线程优化 编辑:程序博客网 时间:2024/05/20 09:44
#include <algorithm>#include <iostream>#include <cstring>#include <cstdio>using namespace std;int a[100005], n, dp[100005], cnt;bool cmp1(int x, int y){ return x>=y;}int main(){ while(scanf("%d", &a[++n])!=EOF) ; n--; dp[0] = 0x3f3f3f3f; for(int i=1; i<=n; i++){ if(a[i]<=dp[cnt]) dp[++cnt] = a[i]; else *lower_bound(dp+1, dp+1+cnt, a[i], cmp1) = a[i]; } cout<<cnt<<endl; memset(dp, 0, sizeof(dp)); cnt = 0; for(int i=1; i<=n; i++){ if(a[i]>dp[cnt]) dp[++cnt] = a[i]; else *upper_bound(dp+1, dp+1+cnt, a[i]) = a[i]; } cout<<cnt; return 0;}
阅读全文
0 0
- luogu1020 导弹拦截
- luogu1020【1999提高】导弹拦截(dp)
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 导弹拦截
- 导弹拦截
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 先序输出叶节点
- Jzoj5421 嘟嘟噜
- 线程的创建方式
- 各种滤波算法的比较
- 二叉树
- luogu1020 导弹拦截
- Windows10+Visual Studio2013+caffe GPU+CPU环境详细配置
- Java代码将数据导出到Excel
- c++虚拟成员函数
- 事件深入应用
- EditPlus-注册码
- 校内八连测 第一试
- 使用web.py接收post数据时中文变成&#xxxxx;的问题
- 浅谈安卓框架mvp