結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2022-12-20 19:14:38
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 1,857 ms / 5,000 ms
コード長 676 bytes
コンパイル時間 1,287 ms
コンパイル使用メモリ 144,232 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 02:01:50
合計ジャッジ時間 43,854 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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<100; i++){
        c = (l+r)/2;
        if (solve(c)) l=c;
        else r=c;
    }

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

    return 0;
}
0