結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー face4face4
提出日時 2018-09-24 15:38:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 658 bytes
コンパイル時間 936 ms
コンパイル使用メモリ 75,300 KB
実行使用メモリ 4,916 KB
最終ジャッジ日時 2023-10-22 02:38:19
合計ジャッジ時間 8,128 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 214 ms
4,916 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 185 ms
4,916 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 208 ms
4,916 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 161 ms
4,652 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 176 ms
4,652 KB
testcase_16 AC 186 ms
4,916 KB
testcase_17 AC 186 ms
4,916 KB
testcase_18 AC 182 ms
4,916 KB
testcase_19 AC 204 ms
4,916 KB
testcase_20 AC 206 ms
4,916 KB
testcase_21 AC 206 ms
4,916 KB
testcase_22 AC 165 ms
4,652 KB
testcase_23 AC 172 ms
4,916 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 3 ms
4,348 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;
const ll inc = 1000000000;

int n, k;
vector<ll> l;

bool check(ll a){
    ll cnt = 0;
    for(int i = 0; i < l.size(); i++)   cnt += l[i] / a;
    return cnt >= k;
}

int main(){
    cin >> n;

    l.resize(n);
    for(int i = 0; i < n; i++)  cin >> l[i], l[i] *= inc;

    cin >> k;

    ll lower = 1, upper = inc*inc;
    while(upper - lower > 1){
        ll mid = (upper + lower) / 2;
        if(check(mid))  lower = mid;
        else            upper = mid-1;
    }

    cout << fixed << setprecision(10) << (double)(upper) / inc << endl;

    return 0;
}
0