結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー kyunakyuna
提出日時 2019-08-11 02:53:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 742 bytes
コンパイル時間 2,364 ms
コンパイル使用メモリ 77,844 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-27 01:25:28
合計ジャッジ時間 8,541 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 200 ms
4,384 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 185 ms
4,380 KB
testcase_17 AC 185 ms
4,380 KB
testcase_18 AC 183 ms
4,384 KB
testcase_19 AC 204 ms
4,380 KB
testcase_20 AC 204 ms
4,380 KB
testcase_21 AC 202 ms
4,380 KB
testcase_22 AC 171 ms
4,380 KB
testcase_23 AC 176 ms
4,376 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
using ll = long long;

vector<int> ls;
ll k;

bool check(double x) {
    ll cnt = 0;
    for (int l: ls) cnt += l / x;
    return cnt >= k;
}

double binary_search(double ok, double ng) {
    assert(check(ok) == true);
    assert(check(ng) == false);
    for (int i = 0; i < 100; i++) {
        double mid = (ng + ok) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    return ok;
}

#include <iomanip>
int main() {
    cout << fixed << setprecision(12);
    int n; cin >> n;
    ls.resize(n);
    for (int &l: ls) cin >> l;
    cin >> k;
    double ok = n / k;
    double ng = 1e12;
    cout << binary_search(ok, ng) << endl;
    return 0;
}
0