P1020 导弹拦截

//#define local
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#define MAXN 2002
using namespace std;
typedef long long ll; 
bool compare(int &a,int &b,int &cheak){
	if(cheak==0)
	return a>b;//严格递增 
	else
	return a>=b;
}
int count(vector<int>&origin,int cheak){
    vector<int>d;
    d.push_back(origin[0]);
    for(int i=1;i<origin.size();++i){
    	if(compare(origin[i],d.back(),cheak))
    	d.push_back(origin[i]);
    	else{
    	vector<int>::iterator it;
    	if(cheak!=0)
    	it=upper_bound(d.begin(),d.end(),origin[i]);
    	else
    	it=lower_bound(d.begin(),d.end(),origin[i]);
    	
		if(it==d.end())
    	d.push_back(origin[i]);
    	else
    	d[it-d.begin()]=origin[i];
    	}
    }
    return (int)d.size();
} 
int main(){
#ifdef local
freopen("data.in","rb",stdin);
//freopen("data.out","wb",stdout);
#endif
int tmp;
vector<int>origin;
while((scanf("%d",&tmp))==1){
	origin.push_back(tmp);
}
int ans=count(origin,0);
reverse(origin.begin(),origin.end());
cout<<count(origin,1)<<endl;
cout<<ans;
return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值