結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー ふーらくたるふーらくたる
提出日時 2016-07-03 15:56:28
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 899 bytes
コンパイル時間 851 ms
コンパイル使用メモリ 78,532 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 21:31:27
合計ジャッジ時間 4,916 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 59 ms
5,376 KB
testcase_03 AC 114 ms
5,376 KB
testcase_04 AC 130 ms
5,376 KB
testcase_05 AC 141 ms
5,376 KB
testcase_06 AC 104 ms
5,376 KB
testcase_07 AC 155 ms
5,376 KB
testcase_08 AC 159 ms
5,376 KB
testcase_09 AC 158 ms
5,376 KB
testcase_10 AC 116 ms
5,376 KB
testcase_11 AC 135 ms
5,376 KB
testcase_12 AC 112 ms
5,376 KB
testcase_13 AC 144 ms
5,376 KB
testcase_14 AC 149 ms
5,376 KB
testcase_15 AC 137 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 4 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 27 ms
5,376 KB
testcase_29 AC 14 ms
5,376 KB
testcase_30 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;

const double kEPS = 1e-10;

int N;
ll K;
vector<int> L;

bool C(double x) {
    ll num = 0;
    for (int i = 0; i < N; i++) {
        num += floor((double)L[i] / x);
        if (num >= K) return true;
    }
    return false;
}

void Solve() {
    sort(L.begin(), L.end(), greater<double>());
    double lb = 0.0, ub = 2e6;
    for (int i = 0; i < 100; i++) {
        double mid = (lb + ub) / 2.0;
        if (C(mid)) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    cout << fixed << setprecision(10) << lb << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    L = vector<int>(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    cin >> K;

    Solve();

    return 0;
}
0