75分 求debug(仅给代码不分析我代码错误的勿扰)
查看原帖
75分 求debug(仅给代码不分析我代码错误的勿扰)
946050
congtianyi_1203楼主2025/6/20 20:04

WA#2

代码如下

#include<bits/stdc++.h>
using namespace std;
int main(){
    int T,ans=0;
    cin>>T;
    deque<int> d;
    while(T--){
        int n;
        cin>>n;
        d.push_back(n);
    }
    sort(d.begin(),d.end());
    for(ans=1;;ans++){
    	if(d.empty()){
			break;
		}
        for(int s=0;s!=1;){
			if(d[0]>=ans){
				s++;
			}
            d.pop_front();
            if(d.empty()){
				break;
			}
		}
    }
    cout<<ans-1;
    return 0;
}
2025/6/20 20:04
加载中...