結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー focusfocus
提出日時 2018-01-12 15:44:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 221 ms / 5,000 ms
コード長 626 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 62,864 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 00:24:16
合計ジャッジ時間 6,549 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 221 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 81 ms
6,940 KB
testcase_03 AC 155 ms
6,944 KB
testcase_04 AC 191 ms
6,940 KB
testcase_05 AC 191 ms
6,944 KB
testcase_06 AC 192 ms
6,944 KB
testcase_07 AC 215 ms
6,940 KB
testcase_08 AC 215 ms
6,944 KB
testcase_09 AC 215 ms
6,940 KB
testcase_10 AC 173 ms
6,940 KB
testcase_11 AC 183 ms
6,940 KB
testcase_12 AC 167 ms
6,944 KB
testcase_13 AC 196 ms
6,944 KB
testcase_14 AC 204 ms
6,944 KB
testcase_15 AC 183 ms
6,944 KB
testcase_16 AC 192 ms
6,944 KB
testcase_17 AC 191 ms
6,940 KB
testcase_18 AC 191 ms
6,940 KB
testcase_19 AC 212 ms
6,940 KB
testcase_20 AC 214 ms
6,940 KB
testcase_21 AC 214 ms
6,940 KB
testcase_22 AC 173 ms
6,944 KB
testcase_23 AC 182 ms
6,944 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 6 ms
6,944 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 3 ms
6,944 KB
testcase_28 AC 36 ms
6,944 KB
testcase_29 AC 18 ms
6,940 KB
testcase_30 AC 7 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;
typedef long long ll;
ll K;
vector<ll> L;
bool split(double num){
    ll eda=0;
    for(int i=0;i<L.size();i++){
        eda+=L[i]/num;
    }
    if(eda>=K)  return true;
    return false;
}
int main(){
    double lb=0,ub=0,mid;
    ll N,x;
    cin >> N;
    while(N--){
        cin >> x;
        L.push_back(x);
        if(ub<x)    ub = x;
    }
    cin >> K;
    int limit=100;
    do{
        mid=(lb+ub)/2;
        if(split(mid))    lb=mid;
        else    ub=mid;
    }while(limit--);
    printf("%.10lf\n",lb);
    return 0;
}
0