結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー kaito_tateyamakaito_tateyama
提出日時 2019-03-06 12:50:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 116 ms / 5,000 ms
コード長 1,071 bytes
コンパイル時間 802 ms
コンパイル使用メモリ 83,484 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 00:37:20
合計ジャッジ時間 4,586 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 45 ms
6,944 KB
testcase_03 AC 83 ms
6,944 KB
testcase_04 AC 111 ms
6,940 KB
testcase_05 AC 111 ms
6,944 KB
testcase_06 AC 110 ms
6,944 KB
testcase_07 AC 114 ms
6,940 KB
testcase_08 AC 114 ms
6,944 KB
testcase_09 AC 114 ms
6,940 KB
testcase_10 AC 100 ms
6,944 KB
testcase_11 AC 105 ms
6,944 KB
testcase_12 AC 96 ms
6,944 KB
testcase_13 AC 104 ms
6,940 KB
testcase_14 AC 108 ms
6,940 KB
testcase_15 AC 97 ms
6,940 KB
testcase_16 AC 111 ms
6,944 KB
testcase_17 AC 112 ms
6,940 KB
testcase_18 AC 111 ms
6,940 KB
testcase_19 AC 114 ms
6,940 KB
testcase_20 AC 114 ms
6,940 KB
testcase_21 AC 115 ms
6,940 KB
testcase_22 AC 100 ms
6,940 KB
testcase_23 AC 106 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 4 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 3 ms
6,940 KB
testcase_28 AC 20 ms
6,940 KB
testcase_29 AC 11 ms
6,940 KB
testcase_30 AC 4 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define P(x) cout << (x) << "\n"
#define D(x) cerr << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

using i64 = long long int; // 10^18
static const double eps = (1e-10);

vector<double> l;
i64 k;
bool isOK(double s)
{
    double sum = 0;
    for (auto ll : l)
    {
        sum += (i64)floor(ll / s);
    }
    return sum >= k;
}
double binary_search()
{
    double ng = 0;
    double ok = 10000000000;
    int i=0;
    while (i<100)
    {
        double mid = ng + (double (ok - ng)) / 2;
        if (!isOK(mid))
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
        i++;
    }
    return ok;
}

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

    int n;
    cin >> n;
    REP(i, n)
    {
        double ll;
        cin >> ll;
        l.push_back(ll);
    }
    cin >> k;
    fcout<< binary_search() <<endl;
    return 0;
}
0