86分WA求助
查看原帖
86分WA求助
602932
NumberTrart楼主2023/1/5 14:59

评测结果——1个AC,20个WA

#include <iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int n,a/*导弹高度*/[100005],h/*系统高度,在后面的代码中自动从小到大排序,以配合lower_bound*/[100005],cnt,t/*拦截导弹个数,用于计算第一问*/[100005];
int main() {
    n=0;
	while(cin>>a[++n]);
	int ans=-1;
	cnt=0;
	for(int i=1;i<=n;i++)
	{
        int p=lower_bound(h+1,h+cnt+1,a[i])-h;
        if(p>cnt)
        {
            h[++cnt]=a[i];
            t[cnt]=1;
            ans=max(ans,t[cnt]);
        }
        else
        {
            h[p]=a[i];
            t[p]++;
            ans=max(ans,t[p]);
            while(h[p]<h[p-1]&&p>=2)
            {
                swap(h[p],h[p-1]);
                swap(t[p],t[p-1]);
                p--;
            }
        }
	}
	cout<<ans<<endl;
	cout<<cnt;
    return 0;
}
2023/1/5 14:59
加载中...