Submission #46172028


Source Code Expand

use proconio::input;
use superslice::Ext;

fn main() {
    input! {
        n: usize,
        m: usize,
        p: i64,
        a: [i64; n],
        mut b: [i64; m],
    };

    b.sort();

    let s = std::iter::once(0)
        .chain(b.iter().scan(0, |acc, &i| {
            *acc += i;
            Some(*acc)
        }))
        .collect::<Vec<i64>>();

    let mut sum = 0_i64;
    for a_i in a {
        if a_i >= p {
            sum += p * m as i64;
            continue;
        }

        let count = b.lower_bound(&(p - a_i));
        sum += s[count] + a_i * count as i64;
        sum += (m - count) as i64 * p;
    }
    let ans = sum;
    println!("{}", ans);
}

Submission Info

Submission Time
Task D - Set Menu
User bouzuya
Language Rust (rustc 1.70.0)
Score 400
Code Size 671 Byte
Status AC
Exec Time 47 ms
Memory 11044 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 30
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 02_handmade_00.txt, 02_handmade_01.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 0 ms 1856 KiB
00_sample_01.txt AC 0 ms 1924 KiB
00_sample_02.txt AC 0 ms 1940 KiB
01_random_00.txt AC 0 ms 2064 KiB
01_random_01.txt AC 22 ms 7224 KiB
01_random_02.txt AC 6 ms 5032 KiB
01_random_03.txt AC 24 ms 6588 KiB
01_random_04.txt AC 36 ms 10660 KiB
01_random_05.txt AC 8 ms 4608 KiB
01_random_06.txt AC 5 ms 3112 KiB
01_random_07.txt AC 14 ms 5000 KiB
01_random_08.txt AC 22 ms 7016 KiB
01_random_09.txt AC 16 ms 5296 KiB
01_random_10.txt AC 47 ms 10652 KiB
01_random_11.txt AC 7 ms 3244 KiB
01_random_12.txt AC 37 ms 10592 KiB
01_random_13.txt AC 38 ms 10668 KiB
01_random_14.txt AC 17 ms 5260 KiB
01_random_15.txt AC 22 ms 10620 KiB
01_random_16.txt AC 22 ms 10648 KiB
01_random_17.txt AC 21 ms 10540 KiB
01_random_18.txt AC 21 ms 10648 KiB
01_random_19.txt AC 21 ms 10540 KiB
01_random_20.txt AC 19 ms 8260 KiB
01_random_21.txt AC 19 ms 8324 KiB
01_random_22.txt AC 20 ms 8264 KiB
01_random_23.txt AC 19 ms 8264 KiB
01_random_24.txt AC 20 ms 8264 KiB
02_handmade_00.txt AC 1 ms 1864 KiB
02_handmade_01.txt AC 16 ms 11044 KiB