結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー MisterMister
提出日時 2020-08-22 08:34:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 242 ms / 5,000 ms
コード長 825 bytes
コンパイル時間 1,069 ms
コンパイル使用メモリ 98,196 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 01:09:09
合計ジャッジ時間 7,772 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 242 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 93 ms
6,944 KB
testcase_03 AC 174 ms
6,940 KB
testcase_04 AC 236 ms
6,940 KB
testcase_05 AC 237 ms
6,944 KB
testcase_06 AC 237 ms
6,940 KB
testcase_07 AC 240 ms
6,944 KB
testcase_08 AC 239 ms
6,940 KB
testcase_09 AC 240 ms
6,944 KB
testcase_10 AC 214 ms
6,944 KB
testcase_11 AC 226 ms
6,944 KB
testcase_12 AC 204 ms
6,940 KB
testcase_13 AC 219 ms
6,944 KB
testcase_14 AC 227 ms
6,940 KB
testcase_15 AC 206 ms
6,944 KB
testcase_16 AC 237 ms
6,944 KB
testcase_17 AC 237 ms
6,940 KB
testcase_18 AC 235 ms
6,940 KB
testcase_19 AC 241 ms
6,944 KB
testcase_20 AC 242 ms
6,940 KB
testcase_21 AC 240 ms
6,944 KB
testcase_22 AC 213 ms
6,944 KB
testcase_23 AC 226 ms
6,940 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 7 ms
6,940 KB
testcase_26 AC 4 ms
6,940 KB
testcase_27 AC 3 ms
6,944 KB
testcase_28 AC 40 ms
6,940 KB
testcase_29 AC 21 ms
6,944 KB
testcase_30 AC 7 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>

using ldouble = long double;
using lint = long long;

constexpr ldouble INF = 1e10;

void solve() {
    int n;
    std::cin >> n;

    std::vector<ldouble> xs(n);
    for (auto& x : xs) std::cin >> x;

    lint k;
    std::cin >> k;

    ldouble ok = 0, ng = INF;
    for (int t = 0; t < 100; ++t) {
        ldouble mid = (ok + ng) / 2;

        lint cnt = 0;
        for (auto x : xs) {
            cnt += std::llround(std::floor(x / mid));
        }

        if (cnt >= k) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    std::cout << ok << "\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);

    solve();

    return 0;
}
0