結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー otsnskotsnsk
提出日時 2014-12-27 20:03:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 38 ms / 5,000 ms
コード長 872 bytes
コンパイル時間 578 ms
コンパイル使用メモリ 62,528 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-25 23:13:22
合計ジャッジ時間 2,661 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 15 ms
6,940 KB
testcase_03 AC 28 ms
6,940 KB
testcase_04 AC 35 ms
6,940 KB
testcase_05 AC 35 ms
6,940 KB
testcase_06 AC 34 ms
6,944 KB
testcase_07 AC 38 ms
6,940 KB
testcase_08 AC 37 ms
6,940 KB
testcase_09 AC 38 ms
6,940 KB
testcase_10 AC 30 ms
6,940 KB
testcase_11 AC 31 ms
6,944 KB
testcase_12 AC 30 ms
6,944 KB
testcase_13 AC 34 ms
6,948 KB
testcase_14 AC 35 ms
6,944 KB
testcase_15 AC 32 ms
6,940 KB
testcase_16 AC 35 ms
6,940 KB
testcase_17 AC 34 ms
6,940 KB
testcase_18 AC 34 ms
6,940 KB
testcase_19 AC 38 ms
6,944 KB
testcase_20 AC 38 ms
6,940 KB
testcase_21 AC 37 ms
6,944 KB
testcase_22 AC 29 ms
6,940 KB
testcase_23 AC 33 ms
6,944 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 1 ms
6,948 KB
testcase_28 AC 7 ms
6,940 KB
testcase_29 AC 5 ms
6,940 KB
testcase_30 AC 2 ms
6,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>

#define FORR(i,b,e) for(int i=(b);i<(int)(e);++i)
#define FOR(i,e) FORR(i,0,e)
#define dump(var) cerr << #var ": " << var << "\n"
#define dumpc(con) for(auto& e: con) cerr << e << " "; cerr<<"\n"

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int L[200010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    ll K;
    double lmax = 0;
    cin >> N;
    FOR(i, N) {
        cin >> L[i];
        lmax += L[i];
    }
    cin >> K;
    lmax /= K;

    double l = 0.0, u = lmax, m;
    FOR(i, 50) {
        m = (l+u)/2;
        ll cnt = 0;
        FOR(j, N) {
            cnt += (ll)(L[j]/m);
        }
        if (cnt < K) {
            u = m;
        }
        else {
            l = m;
        }
    }
    cout << fixed << setprecision(10) << m << endl;
    
    return 0;
}
0