提出 #34474948


ソースコード 拡げる

use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    };
    let max = a.iter().copied().max().unwrap();
    if a.iter().copied().filter(|a_i| a_i == &max).count() >= 2 {
        for _ in a {
            println!("{}", max);
        }
        return;
    }
    let mut b = a.clone();
    b.sort();
    b.reverse();
    let max2 = b[1];

    for a_i in a {
        let ans = if a_i != max { max } else { max2 };
        println!("{}", ans);
    }
}

提出情報

提出日時
問題 C - Exception Handling
ユーザ bouzuya
言語 Rust (1.42.0)
得点 300
コード長 486 Byte
結果 AC
実行時間 343 ms
メモリ 7056 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 2
AC × 12
セット名 テストケース
Sample a01, a02
All a01, a02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12
ケース名 結果 実行時間 メモリ
a01 AC 6 ms 2004 KiB
a02 AC 1 ms 2000 KiB
b03 AC 3 ms 2020 KiB
b04 AC 2 ms 2072 KiB
b05 AC 2 ms 2108 KiB
b06 AC 326 ms 4800 KiB
b07 AC 318 ms 5612 KiB
b08 AC 326 ms 6468 KiB
b09 AC 320 ms 4552 KiB
b10 AC 343 ms 7056 KiB
b11 AC 317 ms 4816 KiB
b12 AC 318 ms 4560 KiB