結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー legosuke
提出日時 2020-02-28 15:37:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 56 ms / 5,000 ms
コード長 633 bytes
コンパイル時間 2,448 ms
コンパイル使用メモリ 192,520 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-03-03 11:31:29
合計ジャッジ時間 4,964 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N, K;
int L[200010];

bool check(double x) {
    int num = 0;
    REP (i, N) num += (int)(L[i] / x);
    return (num >= K);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);

    cin >> N;
    REP (i, N) cin >> L[i];
    cin >> K;
    double ok = 0, ng = 1e9;
    REP (i, 100) {
        double m = (ok + ng) / 2;
        if (check(m)) ok = m;
        else ng = m;
    }
    cout << ok << endl;
}
0