結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー PachicobuePachicobue
提出日時 2017-07-17 01:23:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,306 ms / 5,000 ms
コード長 1,291 bytes
コンパイル時間 1,753 ms
コンパイル使用メモリ 166,448 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 00:05:12
合計ジャッジ時間 32,489 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,306 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 495 ms
6,944 KB
testcase_03 AC 942 ms
6,940 KB
testcase_04 AC 1,281 ms
6,944 KB
testcase_05 AC 1,278 ms
6,940 KB
testcase_06 AC 1,280 ms
6,944 KB
testcase_07 AC 1,303 ms
6,940 KB
testcase_08 AC 1,300 ms
6,940 KB
testcase_09 AC 1,304 ms
6,940 KB
testcase_10 AC 1,157 ms
6,940 KB
testcase_11 AC 1,219 ms
6,940 KB
testcase_12 AC 1,098 ms
6,944 KB
testcase_13 AC 1,171 ms
6,944 KB
testcase_14 AC 1,235 ms
6,940 KB
testcase_15 AC 1,103 ms
6,944 KB
testcase_16 AC 1,280 ms
6,940 KB
testcase_17 AC 1,283 ms
6,944 KB
testcase_18 AC 1,286 ms
6,944 KB
testcase_19 AC 1,304 ms
6,940 KB
testcase_20 AC 1,296 ms
6,940 KB
testcase_21 AC 1,290 ms
6,940 KB
testcase_22 AC 1,147 ms
6,944 KB
testcase_23 AC 1,205 ms
6,940 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 27 ms
6,940 KB
testcase_26 AC 11 ms
6,944 KB
testcase_27 AC 8 ms
6,940 KB
testcase_28 AC 206 ms
6,940 KB
testcase_29 AC 101 ms
6,940 KB
testcase_30 AC 27 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define show(x) cout << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

int main()
{
    ll N;
    cin >> N;
    vector<ll> L(N);
    for (ll i = 0; i < N; i++) {
        cin >> L[i];
    }
    ll K;
    cin >> K;

    constexpr long double eps = 1e-9;
    long double inf = 0;
    long double sup = 1e9;
    while (abs(inf - sup) > eps) {
        const long double mid = (inf + sup) / 2;
        ll num = 0;
        for (ll i = 0; i < N; i++) {
            num += static_cast<ll>(floorl(static_cast<long double>(L[i]) / mid));
        }
        if (num < K) {
            sup = mid;
        } else {
            inf = mid;
        }
    }
    cout << fixed << setprecision(10) << inf << endl;

    return 0;
}
0