結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー ninoinuininoinui
提出日時 2020-09-26 02:53:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 272 ms / 5,000 ms
コード長 751 bytes
コンパイル時間 2,322 ms
コンパイル使用メモリ 196,152 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-26 01:11:22
合計ジャッジ時間 9,760 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 272 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 103 ms
6,940 KB
testcase_03 AC 194 ms
6,940 KB
testcase_04 AC 262 ms
6,944 KB
testcase_05 AC 265 ms
6,944 KB
testcase_06 AC 265 ms
6,944 KB
testcase_07 AC 269 ms
6,944 KB
testcase_08 AC 267 ms
6,944 KB
testcase_09 AC 268 ms
6,944 KB
testcase_10 AC 237 ms
6,940 KB
testcase_11 AC 253 ms
6,940 KB
testcase_12 AC 230 ms
6,940 KB
testcase_13 AC 246 ms
6,940 KB
testcase_14 AC 254 ms
6,940 KB
testcase_15 AC 232 ms
6,948 KB
testcase_16 AC 265 ms
6,940 KB
testcase_17 AC 263 ms
6,940 KB
testcase_18 AC 262 ms
6,944 KB
testcase_19 AC 268 ms
6,944 KB
testcase_20 AC 271 ms
6,944 KB
testcase_21 AC 268 ms
6,940 KB
testcase_22 AC 238 ms
6,944 KB
testcase_23 AC 250 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 7 ms
6,940 KB
testcase_26 AC 4 ms
6,944 KB
testcase_27 AC 3 ms
6,940 KB
testcase_28 AC 45 ms
6,944 KB
testcase_29 AC 23 ms
6,940 KB
testcase_30 AC 8 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

template <typename T, typename U> void cmin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U> void cmax(T &a, U b) {
  if (a < b) a = b;
}

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  long N;
  cin >> N;
  vector<long> L(N);
  for (long i = 0; i < N; i++) cin >> L.at(i);
  long K;
  cin >> K;

  auto f = [&](long double mid) {
    long tmp = 0;
    for (auto l : L) tmp += long(l / mid);
    if (tmp >= K) return true;
    else return false;
  };

  long double ok = 1e-10, ng = 1e10 + 1e-10;
  for (long i = 300; i; i--) {
    long double mid = (ok + ng) / 2;
    (f(mid)) ? ok = mid : ng = mid;
  }
  cout << fixed << setprecision(9) << ok << "\n";
}
0