记录编号 123909 评测结果 AAAAAAAAAA
题目名称 帮忙 最终得分 100
用户昵称 GravatarHouJikan 是否通过 通过
代码语言 C++ 运行时间 0.031 s
提交时间 2014-10-01 12:13:09 内存使用 1.08 MiB
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <list>
#include <vector>
#include <ctime>
#include <iterator>
#include <functional>
#define pritnf printf
#define scafn scanf
#define For(i,j,k) for(int i=(j);i<=(k);(i)++)
using namespace std;
typedef long long LL;
typedef unsigned int Uint; 
const int INF=0x7ffffff;
const double eps=1e-6;
//==============struct declaration==============

//==============var declaration=================
const int MAXN=100010;
LL S[MAXN];
deque <int> Q;
int n,k;
double res=0;
//==============function declaration============

//==============main code=======================
int main()
{  
  string FileName="helpz";//程序名 
  string FloderName="COGS";//文件夹名 
  freopen((FileName+".in").c_str(),"r",stdin);
  freopen((FileName+".out").c_str(),"w",stdout);
#ifdef DEBUG  
  clock_t Start_Time=clock();
#endif    
  ios::sync_with_stdio(false);
  cin>>n>>k;
  For(i,1,n){
    cin>>S[i];
    S[i]+=S[i-1];
  }
  For(i,k,n){
    while ((!Q.empty())&&double(S[i]-S[Q.back()-1])/(i-Q.back()+1)<double(S[i]-S[i-k])/k)
      Q.pop_back();
    Q.push_back(i-k+1);
    int x=Q.front();
    res=max(res,double(S[i]-S[x-1])/(i-x+1));
  }
  cout<<int (res*1000)<<endl;
#ifdef DEBUG  
  clock_t End_Time=clock();
  cout<<endl<<endl<<"Time Used: "<<double(End_Time-Start_Time)*1000/(CLOCKS_PER_SEC)<<" Ms"<<endl;
#endif    
  return 0;
}
//================fuction code====================