結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー otsnskotsnsk
提出日時 2014-12-27 20:25:02
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,047 bytes
コンパイル時間 763 ms
コンパイル使用メモリ 61,936 KB
実行使用メモリ 12,960 KB
最終ジャッジ日時 2023-09-03 18:40:45
合計ジャッジ時間 14,991 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

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[100010], K[100010];

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

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

    cout << fixed << setprecision(10);

    FOR(q, Q) {
        double l = 0.0, u = lsum/K[q], m, d;
        FOR(i, 50) {  // (u-l < EPS)
            m = (l+u)/2;
            d = 1 / m;
            ll cnt = 0;
            FOR(j, N) {
                cnt += (ll)(L[j]*d);
            }
            if (cnt < K[q]) {
                u = m;
            }
            else {
                l = m;
            }
        }
        cout << m << "\n";
    }
    
    return 0;
}
0