这题十个点过了七个，求哪里不对？？？？，下面是我打的代码

0

box.cpp box.in box.out 2s 128MB

3
0 0 10

2

4
0 0 0 0

4

30% 数据，1  n  10
60% 数据，1  n  100
80% 数据，1  n  1000
100% 数据，1  n  5000

```#include<iostream>
#include<cstdio>
#include<cmath>
#include<stdio.h>
#include<cstring>
#include<iomanip>
using namespace std;
int qing[5001];
int main()
{
freopen("box.in","r",stdin);
freopen("box.out","w",stdout);
int n,s=1,lie=0;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>qing[i];
}
for(int i=1;i<=n;i++)
{
if(qing[i]==0)
{
lie++;
}
}
for(int i=1;i<=n;i++)
{
int ans=0;
for(int j=1;j<=n;j++)
{
if(qing[j]==i)
{
ans++;
}
}
if(ans>i)
{
s=s+ans-i;
}
}

if(lie>=s)
{
cout<<lie;
}
if(lie<s)
{
cout<<s;
}

return 0;
}```

0

#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int qing[5001];
bool sign[5001];
int main() {
freopen("box.in", "r", stdin);
freopen("box.out", "w", stdout);
int n;
cin >> n;
for(int i=0; i<n; i++)
scanf("%d", &qing[i]);
sort(qing, qing+n);
int sum = 0, ans = 0;
while(sum != n) {
ans++;
int curr = 0;
for(int i=0; i<n; i++) {
if(!sign[i] && qing[i] >= curr) {
sign[i] = true;
curr++;
sum++;
}
}
}
cout << ans << endl;
return 0;
}

0

您需要登录以后才能回答，未注册用户请先注册