比赛 20121023 评测结果 AEEEEEEEEE
题目名称 奶牛晒衣服 最终得分 10
用户昵称 临轩听雨ゐ 运行时间 0.705 s
代码语言 C++ 内存使用 0.28 MiB
提交时间 2012-10-23 21:59:13
显示代码纯文本
  1. #include <fstream>
  2. #include <cstdlib>
  3. #include <cstdio>
  4. using namespace std;
  5. int comp(const void *i1, const void *i2)
  6. {
  7. return *(int*)i2-*(int*)i1;
  8. }
  9.  
  10. int main()
  11. {
  12. ifstream in("dry.in");
  13. ofstream out("dry.out");
  14. int cloth[10];
  15. int a=0, b=0, n=0;
  16. in>>n>>a>>b;
  17. for(int i = 0; i < n; i++)
  18. in>>cloth[i];
  19. int time = 0;
  20. qsort(cloth, n, sizeof(int), comp);
  21. while(cloth[0]!=0)
  22. {
  23. for(int i = 0; i < n; i++)
  24. {
  25. if(i==0)
  26. if(cloth[i]>=a+b)
  27. cloth[i]-=(a+b);
  28. else
  29. cloth[i]=0;
  30. else
  31. if(cloth[i]>=a)
  32. cloth[i]-=a;
  33. else
  34. cloth[i]=0;
  35. }
  36. time++;
  37. qsort(cloth, n, sizeof(int), comp);
  38. }
  39. out<<time<<endl;
  40. }