結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー sio_puyosio_puyo
提出日時 2014-11-16 23:37:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 172 ms / 5,000 ms
コード長 1,200 bytes
コンパイル時間 1,555 ms
コンパイル使用メモリ 147,448 KB
実行使用メモリ 4,884 KB
最終ジャッジ日時 2023-08-08 05:31:02
合計ジャッジ時間 6,138 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 172 ms
4,608 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 56 ms
4,380 KB
testcase_03 AC 105 ms
4,380 KB
testcase_04 AC 124 ms
4,692 KB
testcase_05 AC 124 ms
4,600 KB
testcase_06 AC 124 ms
4,884 KB
testcase_07 AC 144 ms
4,760 KB
testcase_08 AC 145 ms
4,564 KB
testcase_09 AC 145 ms
4,708 KB
testcase_10 AC 112 ms
4,380 KB
testcase_11 AC 118 ms
4,768 KB
testcase_12 AC 108 ms
4,380 KB
testcase_13 AC 132 ms
4,440 KB
testcase_14 AC 137 ms
4,708 KB
testcase_15 AC 123 ms
4,512 KB
testcase_16 AC 124 ms
4,708 KB
testcase_17 AC 126 ms
4,616 KB
testcase_18 AC 138 ms
4,660 KB
testcase_19 AC 148 ms
4,696 KB
testcase_20 AC 165 ms
4,656 KB
testcase_21 AC 163 ms
4,724 KB
testcase_22 AC 127 ms
4,444 KB
testcase_23 AC 131 ms
4,648 KB
testcase_24 AC 1 ms
4,384 KB
testcase_25 AC 5 ms
4,380 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 2 ms
4,384 KB
testcase_28 AC 25 ms
4,384 KB
testcase_29 AC 13 ms
4,380 KB
testcase_30 AC 4 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  int n;
  cin >> n;
  vector<double> l;
  l.resize(n);
  double left=0,right=0;
  REP(i,n) cin >> l[i];
  LL k;
  cin >> k;
  REP(i,n) left=max(left,l[i]);
  left/=k;
  REP(i,n) right+=l[i];
  right/=k;
  while(right-left>EPS&&right>left*(1+EPS)){
    double tmp=(left+right)/2;
    LL stick=0;
    REP(i,l.size()) stick+=l[i]/tmp;
    if(stick<k) right=tmp;
    else left=tmp;
  }
  cout << fixed<<setprecision(10) << (left+right)/2 << endl;
  return 0;
}
0