結果

問題 No.3604 Min of Max of Div of Sum
コンテスト
ユーザー urectanc
提出日時 2026-07-31 22:20:31
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
WA  
実行時間 -
コード長 1,091 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 12,149 ms
コンパイル使用メモリ 184,280 KB
実行使用メモリ 6,040 KB
最終ジャッジ日時 2026-07-31 22:20:46
合計ジャッジ時間 13,891 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// 点列を2つに切る
// 左->右の傾きの最大値を最小化
// abc341?
//
// 1:N or N:1 が最善か
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
        b: [i64; n],
    }

    let mut y = vec![0; n + 1];
    let mut x = vec![0; n + 1];
    for i in 0..n {
        y[i + 1] = y[i] + a[i];
        x[i + 1] = x[i] + b[i];
    }
    // eprintln!("y: {y:?}");
    // eprintln!("x: {x:?}");

    let mut cand1 = (1, 0);
    {
        for i in 1..=n {
            let dx = x[i] - x[0];
            let dy = y[i] - y[0];
            if dx * cand1.1 < dy * cand1.0 {
                cand1 = (dx, dy);
            }
        }
    }
    let mut cand2 = (1, 0);
    {
        for i in 0..n {
            let dx = x[n] - x[i];
            let dy = y[n] - y[i];
            if dx * cand2.1 < dy * cand2.0 {
                cand2 = (dx, dy);
            }
        }
    }

    let ans = if cand1.1 * cand2.0 < cand2.1 * cand1.0 {
        cand1
    } else {
        cand2
    };

    let ans = ans.1 as f64 / ans.0 as f64;
    println!("{ans:.10}");
}
0