結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー ouoz1Vouoz1V
提出日時 2019-10-23 13:16:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 235 ms / 5,000 ms
コード長 891 bytes
コンパイル時間 1,425 ms
コンパイル使用メモリ 144,168 KB
実行使用メモリ 5,204 KB
最終ジャッジ日時 2023-08-08 07:21:10
合計ジャッジ時間 7,860 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 235 ms
5,088 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 88 ms
4,384 KB
testcase_03 AC 167 ms
4,660 KB
testcase_04 AC 210 ms
5,132 KB
testcase_05 AC 209 ms
5,084 KB
testcase_06 AC 209 ms
5,076 KB
testcase_07 AC 228 ms
5,076 KB
testcase_08 AC 230 ms
5,160 KB
testcase_09 AC 229 ms
5,204 KB
testcase_10 AC 189 ms
5,052 KB
testcase_11 AC 199 ms
5,128 KB
testcase_12 AC 181 ms
4,928 KB
testcase_13 AC 210 ms
4,956 KB
testcase_14 AC 218 ms
4,996 KB
testcase_15 AC 196 ms
4,844 KB
testcase_16 AC 210 ms
5,088 KB
testcase_17 AC 210 ms
5,156 KB
testcase_18 AC 209 ms
5,068 KB
testcase_19 AC 230 ms
5,068 KB
testcase_20 AC 229 ms
5,176 KB
testcase_21 AC 229 ms
5,088 KB
testcase_22 AC 188 ms
4,928 KB
testcase_23 AC 200 ms
5,096 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 6 ms
4,380 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 3 ms
4,384 KB
testcase_28 AC 38 ms
4,376 KB
testcase_29 AC 20 ms
4,376 KB
testcase_30 AC 6 ms
4,380 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