結果

問題 No.2648 [Cherry 6th Tune D] 一次元の馬
ユーザー phsplsphspls
提出日時 2024-02-23 21:43:07
言語 Rust
(1.77.0)
結果
AC  
実行時間 327 ms / 2,000 ms
コード長 940 bytes
コンパイル時間 1,681 ms
コンパイル使用メモリ 178,420 KB
実行使用メモリ 10,132 KB
最終ジャッジ日時 2024-02-23 21:43:17
合計ジャッジ時間 4,893 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 98 ms
6,548 KB
testcase_02 AC 43 ms
6,548 KB
testcase_03 AC 43 ms
6,548 KB
testcase_04 AC 46 ms
6,912 KB
testcase_05 AC 48 ms
9,472 KB
testcase_06 AC 46 ms
6,548 KB
testcase_07 AC 47 ms
8,832 KB
testcase_08 AC 46 ms
6,548 KB
testcase_09 AC 49 ms
9,856 KB
testcase_10 AC 48 ms
9,472 KB
testcase_11 AC 48 ms
6,656 KB
testcase_12 AC 48 ms
8,916 KB
testcase_13 AC 46 ms
8,832 KB
testcase_14 AC 46 ms
10,108 KB
testcase_15 AC 47 ms
10,108 KB
testcase_16 AC 47 ms
10,108 KB
testcase_17 AC 47 ms
10,108 KB
testcase_18 AC 47 ms
10,108 KB
testcase_19 AC 47 ms
10,108 KB
testcase_20 AC 48 ms
10,108 KB
testcase_21 AC 48 ms
10,108 KB
testcase_22 AC 48 ms
10,108 KB
testcase_23 AC 47 ms
10,108 KB
testcase_24 AC 49 ms
10,108 KB
testcase_25 AC 49 ms
6,548 KB
testcase_26 AC 47 ms
10,108 KB
testcase_27 AC 48 ms
8,760 KB
testcase_28 AC 49 ms
10,132 KB
testcase_29 AC 50 ms
8,960 KB
testcase_30 AC 47 ms
10,132 KB
testcase_31 AC 48 ms
10,132 KB
testcase_32 AC 48 ms
10,132 KB
testcase_33 AC 48 ms
9,976 KB
testcase_34 AC 48 ms
10,132 KB
testcase_35 AC 327 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

const INF: u128 = 1u128 << 60;

fn main() {
    let mut t = String::new();
    std::io::stdin().read_line(&mut t).ok();
    let t: usize = t.trim().parse().unwrap();
    for _ in 0..t {
        let mut n = String::new();
        std::io::stdin().read_line(&mut n).ok();
        let n: usize = n.trim().parse().unwrap();
        let mut a = String::new();
        std::io::stdin().read_line(&mut a).ok();
        let a: Vec<u128> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();

        let mut lower = 0u128;
        let mut upper = INF;
        while upper > lower {
            let middle = (upper + lower) / 2;
            let next_a = (0..n).map(|i| a[i] + (i as u128 + 1) * middle).collect::<Vec<_>>();
            if next_a.windows(2).all(|lr| lr[0] < lr[1]) {
                upper = middle;
            } else {
                lower = middle + 1;
            }
        }
        println!("{}", upper);
    }
}
0