Run ID:79370

提交时间:2024-07-03 22:40:45

#include<bits/stdc++.h> using namespace std; #define N 1005 #define INF 0x3f3f3f3f int main(){ int a[N],n=1,ct=0,h,ans=0; //ct:拦截的导弹数量 ans:遍历了几趟 bool vis[N]={}; while(cin>>a[n]) n++; n--; while(ct<n){ h=INF; for(int i=1;i<=n;++i){ if(vis[i]==false&&h>=a[i]){ //如果导弹i没被拦截且可以被拦截 h=a[i]; vis[i]=true; ct++; } } ans++; } cout<<ans; return 0; }