結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー YutafuYutafu
提出日時 2023-02-02 19:52:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 209 ms / 5,000 ms
コード長 590 bytes
コンパイル時間 720 ms
コンパイル使用メモリ 74,260 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-15 01:03:28
合計ジャッジ時間 6,599 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 209 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 78 ms
4,376 KB
testcase_03 AC 146 ms
4,376 KB
testcase_04 AC 182 ms
4,380 KB
testcase_05 AC 182 ms
4,376 KB
testcase_06 AC 183 ms
4,376 KB
testcase_07 AC 203 ms
4,376 KB
testcase_08 AC 203 ms
4,376 KB
testcase_09 AC 202 ms
4,376 KB
testcase_10 AC 164 ms
4,380 KB
testcase_11 AC 173 ms
4,380 KB
testcase_12 AC 158 ms
4,380 KB
testcase_13 AC 187 ms
4,376 KB
testcase_14 AC 193 ms
4,376 KB
testcase_15 AC 172 ms
4,376 KB
testcase_16 AC 183 ms
4,376 KB
testcase_17 AC 182 ms
4,380 KB
testcase_18 AC 182 ms
4,380 KB
testcase_19 AC 202 ms
4,380 KB
testcase_20 AC 203 ms
4,380 KB
testcase_21 AC 202 ms
4,380 KB
testcase_22 AC 165 ms
4,380 KB
testcase_23 AC 173 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 5 ms
4,380 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 34 ms
4,380 KB
testcase_29 AC 17 ms
4,376 KB
testcase_30 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
vector<int> L;
long long k;

bool check(double x){
    long long  s = 0;
    for(int i = 0; i < (int)L.size(); i++) s += L[i] / x;
    if(s >= k) return true;
    else return false;
}

int main(){
    int n;
    cin >> n;

    L.assign(n, 0);
    for(int i = 0; i < n; i++) cin >> L[i];
    cin >> k;

    double l = 0, r = 1e18;
    for(int i = 0; i < 100; i++){
        double mid = (l + r) / 2;
        if(check(mid)) l = mid;
        else r = mid;
    }
    
    cout << setprecision(20) << l << endl;
    
}
0