結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー koyoprokoyopro
提出日時 2015-10-01 00:15:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,019 bytes
コンパイル時間 1,653 ms
コンパイル使用メモリ 149,672 KB
実行使用メモリ 9,260 KB
最終ジャッジ日時 2023-09-27 01:07:01
合計ジャッジ時間 10,052 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
9,252 KB
testcase_01 WA -
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
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 "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(int i=0; i<(n); i++)
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define SUM(a) accumulate(ALL(a), 0)
#define FOR(i, a, b) for(int i=(a);i<(b);i++)

int N, K;
vector<int> L(222222);
signed main()
{
    cin >> N;
    REP(i,N) cin >> L[i];
    cin >> K;
    sort(ALL(L));
    reverse(ALL(L));
    double maxl = 1.0 * SUM(L) / K;
    if (K <= N) {
        cout << L[K-1] << endl;
        return 0;
    }

    int cut = (int)(L[0] / maxl);
    while(true) {
        double maxlen = min(1.0 *  L[0] / cut, (double)L[N-1]);
        int cnt = N + cut - 1;
        bool ok = false;
        FOR(i,1,N) {
            if (cnt >= K) {
                ok = true;
                break;
            }
            int cuti = (int)(L[i] / maxlen);
            maxlen = min(maxlen, 1.0 * L[i] / cuti);
            cnt += cut - 1;
        }
        if (ok) {
            printf("%.14f\n", maxlen);
            return 0;
        }
        cut++;
    }
}
0