結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー srjywrdnprkt
提出日時 2022-12-20 19:14:38
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 2,230 ms / 5,000 ms
コード長 676 bytes
コンパイル時間 3,364 ms
コンパイル使用メモリ 148,608 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-03-03 12:04:41
合計ジャッジ時間 54,831 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

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