社区讨论

有何区别?

P1020[NOIP 1999 提高组] 导弹拦截参与者 1已保存回复 0

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
0 条
当前快照
1 份
快照标识符
@lo1yq0g9
此快照首次捕获于
2023/10/23 05:10
2 年前
此快照最后确认于
2023/11/03 05:35
2 年前
查看原帖
不AC代码
CPP
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
    vector<int> a;
    int x;
    while(cin>>x){
        a.push_back(x);
        n++;
    }
    reverse(a.begin(),a.end());
    vector<int> t;
    t.clear();
    for(auto e:a){
        auto it=upper_bound(t.begin(),t.end(),e);
        if(it==t.end()) t.push_back(e);
        else *it=e;
    }
    cout<<t.size()<<endl;
    t.clear();
    reverse(a.begin(),a.end());
    for(auto e:a){
        auto it=upper_bound(t.begin(),t.end(),e);
        if(it==t.end()) t.push_back(e);
        else *it=e;
    }
    cout<<t.size()<<endl;
    return 0;
}
AC代码 手写二分查找能过

回复

0 条回复,欢迎继续交流。

正在加载回复...