首页 > 代码库 > 贪心/CoderForces 228c Fox and Box Accumulation

贪心/CoderForces 228c Fox and Box Accumulation

 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int a[110]; 6 int main() 7 { 8     int n; 9     scanf("%d",&n);10     for (int i=1;i<=n;i++) scanf("%d",&a[i]);11     sort(a+1,a+n+1);12     int left=n;13     int ans=0;14     while (left>0)15     {16         int now=0;17         for (int i=1;i<=n;i++)18         {19             if (now<=a[i])20             {21                 a[i]=-1;22                 now++;23                 left--;24             }25         }26         ans++;27     }28     printf("%d\n",ans);29     return 0;30 }

 

贪心/CoderForces 228c Fox and Box Accumulation