Submission #16516743


Source Code Expand

Copy
use proconio::input;

fn main() {
    input! {
        n: usize,
        ab: [(i64, i64); n],
    };
    let mut c = vec![];
    for (i, &(a_i, b_i)) in ab.iter().enumerate() {
        c.push((a_i + b_i, i));
    }
    c.sort_by_key(|(k, _)| -k);

    let mut odd = true;
    let mut s_a = 0_i64;
    let mut s_b = 0_i64;
    for &(_, i) in c.iter() {
        if odd {
            s_a += ab[i].0;
        } else {
            s_b += ab[i].1;
        }
        odd = !odd;
    }
    let ans = s_a - s_b;
    println!("{}", ans);
}

Submission Info

Submission Time
Task C - Different Strokes
User bouzuya
Language Rust (1.42.0)
Score 400
Code Size 530 Byte
Status AC
Exec Time 36 ms
Memory 7732 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 13
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13
Case Name Status Exec Time Memory
a01 AC 7 ms 2036 KB
a02 AC 2 ms 2000 KB
a03 AC 2 ms 2056 KB
b04 AC 1 ms 2092 KB
b05 AC 16 ms 6432 KB
b06 AC 17 ms 6504 KB
b07 AC 34 ms 7672 KB
b08 AC 33 ms 7672 KB
b09 AC 30 ms 7664 KB
b10 AC 36 ms 7700 KB
b11 AC 30 ms 7592 KB
b12 AC 33 ms 7632 KB
b13 AC 30 ms 7732 KB