导弹拦截 wa+re 不知道错在哪[玄关]
查看原帖
导弹拦截 wa+re 不知道错在哪[玄关]
1022556
D75_RangerL楼主2024/5/11 21:21
#include<bits/stdc++.h>
using namespace std;
long long n,a[1005],b[1005],s=1,s2;
bool cmp(int x,int y){
	return x<y;
}
bool f(int t){
	int x;
	for(int i=0;i<=s;i++){
		if(b[i]>s){
			return 0;
		}
	}
	return 1;
}
int v(int s){
	int x;
	sort(b,b+s,cmp);
	for(int i=0;i<=s;i++){
		if(b[i]>s){
			return i;
		}
	}
}
int main(){
	cin>>a[0];
	for(int i=1;cin>>a[i];i++){
		if(a[i]>a[i-1]&&f(a[i])==1){
			s++;
		}
		else{
			int t=v(s);
			b[t]=a[i];
			s2++;
		}		
	}
	cout<<s2<<endl<<s;
	return 0;
}

2024/5/11 21:21
加载中...