记录编号 117217 评测结果 AAAAAAAAAAAAA
题目名称 网线切割 最终得分 100
用户昵称 GravatarHouJikan 是否通过 通过
代码语言 C++ 运行时间 0.034 s
提交时间 2014-08-28 19:13:27 内存使用 0.39 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;
//==============struct declaration==============

//==============var declaration=================
const double eps=1e-8;
LL length[10010];
LL low=1,high=0,mid;
int n,k;
//==============function declaration============

//==============main code=======================
int main()
{  
  string FileName="cable";//程序名 
  string FloderName="COGS";//文件夹名 
  freopen((FileName+".in").c_str(),"r",stdin);
  freopen((FileName+".out").c_str(),"w",stdout);
#ifdef DEBUG  
  system(("cp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\standard.cpp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\submit.txt").c_str());
  clock_t Start_Time=clock();
#endif      
  scanf("%d%d",&n,&k);
  double len;
  LL sum=0;
  For(i,1,n)
  {
    scanf("%lf",&len);
    length[i]=int (floor(len*100+0.5));
    high=max(high,length[i]);
    sum+=length[i];
  }
  if (sum<k)
  {
    printf("0.00\n");
    return 0;
  }
  high++; 
  while (low+1<high)
  {
    int cnt=0;
    mid=(low+high)/2;
    For(i,1,n)
      cnt+=length[i]/mid;
    if (cnt>=k)
      low=mid;
    else
      high=mid;
  }
  printf("%d.",low/100);
  if (low%100<10)
    printf("0%d\n",low%100);
  else
    printf("%d\n",low%100);
#ifdef DEBUG  
  clock_t End_Time=clock();
  printf("\n\nTime Used: %.3lf\n",End_Time-Start_Time);
#endif    
  return 0;
}
//================fuction code====================