海底捞
查看原帖
海底捞
284855
lihaochen_harold楼主2020/11/24 21:42

蒟蒻求助

本蒟蒻想问一问各位大佬vector的insert操作的复杂度,因为(普及组第二题):

#include<bits/stdc++.h>
#define N 100009
using namespace std;
int n,w;
vector<int>p;
int main(){
    cin>>n>>w;
    for(int i=1;i<=n;i++){
        int a;
        cin>>a;
        p.insert(upper_bound(p.begin(),p.end(),a),a);
        cout<<p[i-max(1,i*w/100)];!
        if(i!=n)cout<<' ';
    }
    return 0;
}

这个煞笔代码居然AC了?¿

2020/11/24 21:42
加载中...