提出 #29963634


ソースコード 拡げる

use proconio::input;

fn main() {
    input! {
        n: usize,
        mut a: [i64; n],
    };
    a.sort();
    let mut ans = 0_i64;
    for (i, a_i) in a.iter().copied().enumerate() {
        ans += a_i * i as i64 - a_i * (n as i64 - 1 - i as i64);
    }
    println!("{}", ans);
}

提出情報

提出日時
問題 076 - Sum of difference
ユーザ bouzuya
言語 Rust (1.42.0)
得点 400
コード長 286 Byte
結果 AC
実行時間 42 ms
メモリ 6136 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 2
AC × 25
セット名 テストケース
Sample sample_01.txt, sample_02.txt
All hand_01.txt, max_01.txt, max_02.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, sample_01.txt, sample_02.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 6 ms 2004 KiB
max_01.txt AC 27 ms 6084 KiB
max_02.txt AC 18 ms 5424 KiB
random_01.txt AC 36 ms 6080 KiB
random_02.txt AC 39 ms 6004 KiB
random_03.txt AC 40 ms 5988 KiB
random_04.txt AC 37 ms 6072 KiB
random_05.txt AC 40 ms 6084 KiB
random_06.txt AC 39 ms 6024 KiB
random_07.txt AC 37 ms 6136 KiB
random_08.txt AC 39 ms 6120 KiB
random_09.txt AC 36 ms 6088 KiB
random_10.txt AC 42 ms 6000 KiB
random_11.txt AC 37 ms 5880 KiB
random_12.txt AC 36 ms 6028 KiB
random_13.txt AC 38 ms 6028 KiB
random_14.txt AC 39 ms 6072 KiB
random_15.txt AC 40 ms 6084 KiB
random_16.txt AC 37 ms 6004 KiB
random_17.txt AC 38 ms 6068 KiB
random_18.txt AC 38 ms 5972 KiB
random_19.txt AC 38 ms 6080 KiB
random_20.txt AC 37 ms 6064 KiB
sample_01.txt AC 2 ms 1944 KiB
sample_02.txt AC 1 ms 1944 KiB