結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー alpha_virginisalpha_virginis
提出日時 2016-12-12 23:57:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 184 ms / 5,000 ms
コード長 917 bytes
コンパイル時間 1,852 ms
コンパイル使用メモリ 164,152 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 23:46:14
合計ジャッジ時間 6,981 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 182 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 69 ms
6,940 KB
testcase_03 AC 130 ms
6,944 KB
testcase_04 AC 182 ms
6,940 KB
testcase_05 AC 182 ms
6,940 KB
testcase_06 AC 181 ms
6,944 KB
testcase_07 AC 181 ms
6,940 KB
testcase_08 AC 184 ms
6,940 KB
testcase_09 AC 184 ms
6,944 KB
testcase_10 AC 164 ms
6,944 KB
testcase_11 AC 168 ms
6,944 KB
testcase_12 AC 154 ms
6,944 KB
testcase_13 AC 165 ms
6,940 KB
testcase_14 AC 175 ms
6,940 KB
testcase_15 AC 154 ms
6,944 KB
testcase_16 AC 182 ms
6,940 KB
testcase_17 AC 180 ms
6,940 KB
testcase_18 AC 180 ms
6,940 KB
testcase_19 AC 182 ms
6,940 KB
testcase_20 AC 181 ms
6,944 KB
testcase_21 AC 182 ms
6,944 KB
testcase_22 AC 164 ms
6,944 KB
testcase_23 AC 167 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 5 ms
6,944 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 3 ms
6,940 KB
testcase_28 AC 30 ms
6,944 KB
testcase_29 AC 15 ms
6,944 KB
testcase_30 AC 5 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);

long n;
long xs[212345];
long k;

bool check(double x) {
  if( x == 0 ) return false;
  long res = 0;
  for(int i = 0; i < n; ++i) {
    res += (xs[i] / x + 1e-10);
  }
  dumpl(res);
  return k <= res;
}

int main() {
  scanf("%ld", &n);
  for(int i = 0; i < n; ++i) {
    scanf("%ld", &xs[i]);
  }
  scanf("%ld", &k);
  double z = 0;
  double diff = (1LL << 40);
  for(int i = 120; i >= 0; --i) {
    double nz = z + diff;
    diff /= 2;
    dumpd(nz);
    if( check(nz) ) {
      z = nz;
      continue;
    }
  }
  printf("%.20lf\n", z);

  return 0;
}
0