結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー Mister
提出日時 2020-08-22 08:34:09
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 249 ms / 5,000 ms
コード長 825 bytes
コンパイル時間 1,193 ms
コンパイル使用メモリ 94,772 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-03-03 11:43:50
合計ジャッジ時間 7,684 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

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