Submission #45106421


Source Code Expand

use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    };
    let p = 1_000_000_007_usize;
    let mut ans = 0_usize;
    let mut sum = a.iter().copied().sum::<usize>() % p;
    for a_i in a {
        ans += a_i * ((p + sum - a_i) % p);
        ans %= p;
        sum += p - a_i;
        sum %= p;
    }
    println!("{}", ans);
}

Submission Info

Submission Time
Task C - Sum of product of pairs
User bouzuya
Language Rust (1.42.0)
Score 300
Code Size 367 Byte
Status AC
Exec Time 24 ms
Memory 5584 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 19
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All hand_01.txt, hand_02.txt, hand_03.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, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
hand_01.txt AC 5 ms 2132 KiB
hand_02.txt AC 1 ms 2052 KiB
hand_03.txt AC 2 ms 2076 KiB
max_01.txt AC 13 ms 3860 KiB
max_02.txt AC 24 ms 5584 KiB
random_01.txt AC 16 ms 4480 KiB
random_02.txt AC 20 ms 5484 KiB
random_03.txt AC 2 ms 2308 KiB
random_04.txt AC 22 ms 5348 KiB
random_05.txt AC 8 ms 3016 KiB
random_06.txt AC 18 ms 5288 KiB
random_07.txt AC 9 ms 2728 KiB
random_08.txt AC 21 ms 5416 KiB
random_09.txt AC 8 ms 3304 KiB
random_10.txt AC 19 ms 5444 KiB
random_11.txt AC 20 ms 5392 KiB
random_12.txt AC 18 ms 5352 KiB
sample_01.txt AC 2 ms 1956 KiB
sample_02.txt AC 2 ms 2100 KiB