Fox and Box Accumulation
2014-02-08 21:34
330 查看
while中的每一个for循环都是一摞箱子,用num表示当前是这一摞的第几个,只有a[i]>=num时,才能往下放。
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; int main() { int n,a[110],i,p,q,num; while(scanf("%d",&n)!=EOF) { for(i=1;i<=n;i++) scanf("%d",&a[i]); sort(a+1,a+1+n); q=n;p=0; while(q) { num=0; for(i=1;i<=n;i++) { if(a[i]>=num) { num++; a[i]=-1; q--; } } p++; } printf("%d\n",p); } return 0; }
相关文章推荐
- codeforces-388A-Fox and Box Accumulation
- CF228C题Fox and Box Accumulation
- Codeforces Round #228 (Div. 1)A. Fox and Box Accumulation(逆向思维)
- A. Fox and Box Accumulation
- A. Fox and Box Accumulation
- 贪心-codeforces-388A-Fox and Box Accumulation
- Codeforces #228 (Div. 2)C. Fox and Box Accumulation
- Codeforces Round #228 (Div. 2)C. Fox and Box Accumulation
- [Codeforces] 389C - Fox and Box Accumulation
- Codeforces Round #228 (Div. 2) C Fox and Box Accumulation(贪心)
- Fox and Box Accumulation CodeForces - 388A
- Codeforces Round #228 (Div. 1) A. Fox and Box Accumulation 贪心
- codeforces389 C. Fox and Box Accumulation【简单贪心】
- Codeforces Round #228 (Div. 2)C. Fox and Box Accumulation
- Codeforces Round #228 (Div. 1) A. Fox and Box Accumulation
- Codeforces Round #228 (Div. 1) A. Fox and Box Accumulation 贪心
- CF 388A:Fox and Box Accumulation
- cf228 div2 C. Fox and Box Accumulation(贪心, 二分)
- 【贪心+简单题】-CF-388A-A fox and box accumulation
- Codeforces Round #228 (Div. 2) C. Fox and Box Accumulation