记录编号 92663 评测结果 AAAAAAAAAA
题目名称 帮忙 最终得分 100
用户昵称 GravatarOIdiot 是否通过 通过
代码语言 C++ 运行时间 0.017 s
提交时间 2014-03-21 22:04:00 内存使用 1.08 MiB
显示代码纯文本
  1. #include <iostream>
  2. #include <cstring>
  3. #include <cstdio>
  4. #define INF (1<<30)
  5. #define MAXN 100010
  6. #define eps 1000
  7. #define SpeedUp ios::sync_with_stdio(false)
  8. #define FILE
  9. using namespace std;
  10.  
  11. int Weight[MAXN],f[MAXN];
  12. int N,K;
  13. double Ans;
  14.  
  15. inline double MagicLin(int a,int b){
  16. return (double)(f[a]-f[b])/(double)(a-b);
  17. }
  18.  
  19. void init()
  20. {
  21. SpeedUp;
  22. #ifdef FILE
  23. freopen("helpz.in","r",stdin);
  24. freopen("helpz.out","w",stdout);
  25. #endif
  26. cin>>N>>K;
  27. for(int i=1;i<=N;i++)
  28. {
  29. cin>>Weight[i];
  30. f[i]=f[i-1]+Weight[i];
  31. }
  32. Ans=0;
  33. }
  34.  
  35. void work()
  36. {
  37. int Max=0;
  38. for(int i=0;i<=N-K;i++)
  39. {
  40. if(MagicLin(i+K,Max)<MagicLin(i+K,i))
  41. Max=i;
  42. if(MagicLin(i+K,Max)>Ans)
  43. Ans=MagicLin(i+K,Max);
  44. }
  45. }
  46.  
  47. int main()
  48. {
  49. init();
  50. work();
  51. cout<<(int)(Ans*eps)<<endl;
  52. return 0;
  53. }
  54.