- 难解的问题
- 2018-08-13 20:50:37 @
#include "bits/stdc++.h"
using namespace std;
int stack_[300005],n,k,tmp,top=0;
int main()
{
std::ios::sync_with_stdio(false);
freopen("sample.txt","r",stdin);
cin>>n>>k;
stack_[0]=-1;
for(int i=1;i<=n;i++){
cin>>tmp;
if(i==k){
while(top>=0)
if(tmp<=stack_[top]) stack_[top--]=0;
else break;
stack_[++top]=tmp;
}
else
if(tmp>stack_[top]) stack_[++top]=tmp;
else{
int j=lower_bound(stack_,stack_+top,tmp)-stack_;
stack_[j]=tmp;
}
}
cout<<top<<endl;
}
1 条评论
-
mysuli LV 7 @ 2018-08-14 23:20:59
0.0查出问题了,已发题解
- 1