結果

問題 No.67 よくある棒を切る問題 (1)
コンテスト
ユーザー vjudge1
提出日時 2026-08-24 23:59:32
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.90.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 119 ms / 5,000 ms
+ 152µs
コード長 722 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,229 ms
コンパイル使用メモリ 203,220 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-08-24 23:59:48
合計ジャッジ時間 6,267 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    long long n;
    cin >> n;
    vector<long long> ls(n);
    long long nmax = 0,kq = -1;
    for(long long i=0; i<n; i++) {
        cin >> ls[i];
        nmax = nmax + ls[i];
    }
    long long k;
    cin >> k;
    double l = 0, r = 1e9;
    for(long long it=0; it<100; it++) {
        double mid = (l+r)/2;
        long long tong =0;
        for(long long i=0; i<n; i++) {
            tong += (long long)ls[i]/mid;
            if(tong >= k) break;
        }
        if(tong >=k) {
            l = mid;
        }else {
            r= mid;
        }
    }
    cout << fixed << setprecision(15) << l;
}
0