結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2022-12-20 19:18:03
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 1,363 ms / 5,000 ms
コード長 675 bytes
コンパイル時間 1,459 ms
コンパイル使用メモリ 144,732 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2024-11-18 02:02:54
合計ジャッジ時間 33,286 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>

using namespace std;

long long N, K;
vector<long double> L;

bool solve(long double X){
    long long cnt=0;
    for (int i=0; i<N; i++) cnt += floor(L[i]/X);
    return cnt >= K;
}

int main(){
    cin >> N;
    L.resize(N);
    for (int i=0; i<N; i++) cin >> L[i];
    cin >> K;

    long double l=0, r=1e9, c;
    for (int i=0; i<60; i++){
        c = (l+r)/2;
        if (solve(c)) l=c;
        else r=c;
    }

    cout << setprecision(18) << l << endl;

    return 0;
}
0