結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー ouoz1Vouoz1V
提出日時 2019-10-23 13:16:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 236 ms / 5,000 ms
コード長 891 bytes
コンパイル時間 1,558 ms
コンパイル使用メモリ 158,572 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 00:49:40
合計ジャッジ時間 7,885 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 234 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 88 ms
6,944 KB
testcase_03 AC 169 ms
6,944 KB
testcase_04 AC 209 ms
6,944 KB
testcase_05 AC 208 ms
6,940 KB
testcase_06 AC 209 ms
6,940 KB
testcase_07 AC 230 ms
6,940 KB
testcase_08 AC 232 ms
6,944 KB
testcase_09 AC 236 ms
6,940 KB
testcase_10 AC 192 ms
6,944 KB
testcase_11 AC 195 ms
6,940 KB
testcase_12 AC 180 ms
6,944 KB
testcase_13 AC 210 ms
6,944 KB
testcase_14 AC 225 ms
6,944 KB
testcase_15 AC 196 ms
6,940 KB
testcase_16 AC 210 ms
6,940 KB
testcase_17 AC 214 ms
6,940 KB
testcase_18 AC 211 ms
6,940 KB
testcase_19 AC 229 ms
6,940 KB
testcase_20 AC 232 ms
6,940 KB
testcase_21 AC 233 ms
6,940 KB
testcase_22 AC 193 ms
6,944 KB
testcase_23 AC 202 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 6 ms
6,940 KB
testcase_26 AC 4 ms
6,944 KB
testcase_27 AC 3 ms
6,944 KB
testcase_28 AC 38 ms
6,940 KB
testcase_29 AC 20 ms
6,944 KB
testcase_30 AC 6 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

using ll=long long;
using P=pair<int,int>;

#define int long long 

const int MOD=1e9+7;
const int INF=1<<30;
const int MAX=1e5;

template<class T>
inline void xmin(T &a, T b){a=(a<b)?a:b;}
template<class T>
inline void xmax(T &a, T b){a=(a>b)?a:b;}

int n;
double l[200000];
double k;

bool isOK(double mid, double key){
    int sum=0;
    for(int i=0; i<n; i++){
        sum+=l[i]/mid;
    }
    if(sum>=key)return true;
    else return false;
}

double binary_search(double key){
    double ng=10000000000;
    double ok=0;
    for(int i=0; i<100; i++){
        double mid=(ng+ok)/2;
        if(isOK(mid, key)) ok=mid;
        else ng=mid;
    }
    return ok;
}

void solve(){
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>l[i];
    }
    cin>>k;
    printf("%.12f", binary_search(k));
}

signed main(){
    //while(1)
    solve();
}
0