結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー YutafuYutafu
提出日時 2023-02-02 19:22:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 755 bytes
コンパイル時間 643 ms
コンパイル使用メモリ 79,568 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-15 00:37:38
合計ジャッジ時間 7,878 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 208 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 181 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 201 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 157 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 172 ms
4,380 KB
testcase_16 AC 181 ms
4,384 KB
testcase_17 AC 180 ms
4,376 KB
testcase_18 AC 183 ms
4,376 KB
testcase_19 AC 200 ms
4,376 KB
testcase_20 AC 202 ms
4,380 KB
testcase_21 AC 202 ms
4,376 KB
testcase_22 AC 164 ms
4,376 KB
testcase_23 AC 174 ms
4,380 KB
testcase_24 AC 2 ms
4,384 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

vector<int> L;
int 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;

    /*
    while(r - l > 0.0000000001){
        double mid = (l + r) / 2;
        if(check(mid)) l = mid;
        else r = mid;
    }*/

    for(int i = 0; i < 100; i++){
        double mid = (l + r) / 2;
        if(check(mid)) l = mid;
        else r = mid;
    }

    //cout << l << " " << r << endl;
    cout << setprecision(20) << l << endl;
    
}
0