結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー focusfocus
提出日時 2018-01-12 15:18:17
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 669 bytes
コンパイル時間 701 ms
コンパイル使用メモリ 64,528 KB
実行使用メモリ 9,596 KB
最終ジャッジ日時 2023-08-25 15:34:00
合計ジャッジ時間 10,796 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 154 ms
9,596 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 62 ms
4,376 KB
testcase_03 AC 115 ms
5,216 KB
testcase_04 AC 133 ms
5,012 KB
testcase_05 AC 138 ms
5,076 KB
testcase_06 AC 138 ms
5,100 KB
testcase_07 AC 158 ms
5,068 KB
testcase_08 AC 158 ms
5,056 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

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;
    do{
        mid=(lb+ub)/2;
        if(split(mid))    lb=mid;
        else    ub=mid;
    // cout << lb <<" "<< ub <<" "<< mid << endl;
    }while(ub-lb>0.0000000001);
    printf("%.10lf\n",lb);
    return 0;
}
0