結果

問題 No.1950 片道きゃっちぼーる
ユーザー 👑 zeronosu77108zeronosu77108
提出日時 2022-05-20 23:21:44
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 2,410 bytes
コンパイル時間 1,540 ms
コンパイル使用メモリ 188,404 KB
実行使用メモリ 28,740 KB
最終ジャッジ日時 2023-10-20 14:13:13
合計ジャッジ時間 5,839 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 64 ms
28,076 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 58 ms
27,548 KB
testcase_07 AC 75 ms
28,740 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 73 ms
28,452 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 62 ms
27,812 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 74 ms
28,276 KB
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::BTreeMap;

fn main() {
    let n : usize = input();
    let x : Vec<usize> = input_vec();
    let a : Vec<usize> = input_vec();

    let mut index = (0..n).collect::<Vec<_>>();
    index.sort_by_key(|&i| x[i] + a[i]);

    let mut mp = BTreeMap::new();
    let mut ans = vec![0; n];
    for &i in index.iter().rev() {
        let x = x[i];
        let a = a[i];
        let base = *mp.get(&(x + a)).unwrap_or(&0);
        mp.insert(x, base + a);
        ans[i] = base + a;
    }

    println!("{}", ans.iter().map(|i| i.to_string()).collect::<Vec<_>>().join("\n"));
}

#[allow(dead_code)] fn input<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } #[allow(dead_code)] fn input_t<T: std::str::FromStr, U: std::str::FromStr>() -> (T, U) { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let s = s.trim().split_whitespace().collect::<Vec<&str>>(); (s[0].parse().ok().unwrap(), s[1].parse().ok().unwrap()) } #[allow(dead_code)] fn input_t3<T1: std::str::FromStr, T2: std::str::FromStr, T3: std::str::FromStr>() -> (T1, T2, T3) { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let s = s.trim().split_whitespace().collect::<Vec<&str>>(); (s[0].parse().ok().unwrap(), s[1].parse().ok().unwrap(), s[2].parse().ok().unwrap()) } #[allow(dead_code)] fn input_t4<T1: std::str::FromStr, T2: std::str::FromStr, T3: std::str::FromStr, T4: std::str::FromStr>() -> (T1, T2, T3, T4) { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let s = s.trim().split_whitespace().collect::<Vec<&str>>(); (s[0].parse().ok().unwrap(), s[1].parse().ok().unwrap(), s[2].parse().ok().unwrap(), s[3].parse().ok().unwrap()) } #[allow(dead_code)] fn input_t5<T1: std::str::FromStr, T2: std::str::FromStr, T3: std::str::FromStr, T4: std::str::FromStr, T5: std::str::FromStr>() -> (T1, T2, T3, T4, T5) { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let s = s.trim().split_whitespace().collect::<Vec<&str>>(); (s[0].parse().ok().unwrap(), s[1].parse().ok().unwrap(), s[2].parse().ok().unwrap(), s[3].parse().ok().unwrap(), s[4].parse().ok().unwrap()) } #[allow(dead_code)] fn input_vec<T: std::str::FromStr>() -> Vec<T> { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().split_whitespace().map(|s| s.parse().ok().unwrap()).collect() }
0