Submission #34474948


Source Code Expand

Copy
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 };
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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);
    }
}

Submission Info

Submission Time
Task C - Exception Handling
User bouzuya
Language Rust (1.42.0)
Score 300
Code Size 486 Byte
Status AC
Exec Time 343 ms
Memory 7056 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 12
Set Name Test Cases
Sample a01, a02
All a01, a02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12
Case Name Status Exec Time Memory
a01 AC 6 ms 2004 KB
a02 AC 1 ms 2000 KB
b03 AC 3 ms 2020 KB
b04 AC 2 ms 2072 KB
b05 AC 2 ms 2108 KB
b06 AC 326 ms 4800 KB
b07 AC 318 ms 5612 KB
b08 AC 326 ms 6468 KB
b09 AC 320 ms 4552 KB
b10 AC 343 ms 7056 KB
b11 AC 317 ms 4816 KB
b12 AC 318 ms 4560 KB


2025-04-08 (Tue)
23:11:19 +00:00