0.0为什么第一第二个点过不了,大佬求解

#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 条评论

  • @ 2018-08-14 23:20:59

    0.0查出问题了,已发题解

  • 1

信息

ID
1369
难度
7
分类
动态规划 | LIS 点击显示
标签
递交数
3230
已通过
539
通过率
17%
被复制
3
上传者