結果

問題 No.1090 ソーシャルディスタンス / Social Distance
ユーザー phsplsphspls
提出日時 2020-06-24 23:59:29
言語 Rust
(1.77.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 803 bytes
コンパイル時間 1,163 ms
コンパイル使用メモリ 149,784 KB
実行使用メモリ 10,308 KB
最終ジャッジ日時 2023-09-16 21:28:15
合計ジャッジ時間 3,159 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 12 ms
7,352 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 13 ms
7,944 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 15 ms
9,504 KB
testcase_07 AC 9 ms
5,724 KB
testcase_08 AC 16 ms
9,768 KB
testcase_09 AC 9 ms
5,992 KB
testcase_10 AC 11 ms
7,100 KB
testcase_11 AC 17 ms
9,964 KB
testcase_12 AC 10 ms
6,324 KB
testcase_13 AC 10 ms
5,952 KB
testcase_14 AC 15 ms
9,172 KB
testcase_15 AC 12 ms
7,672 KB
testcase_16 AC 6 ms
4,436 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 6 ms
4,452 KB
testcase_19 AC 8 ms
5,468 KB
testcase_20 AC 7 ms
5,248 KB
testcase_21 AC 10 ms
6,304 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 17 ms
10,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::cmp::max;

fn main() {
    let mut nd = String::new();
    std::io::stdin().read_line(&mut nd).ok();
    let nd: Vec<usize> = nd.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nd[0];
    let d = nd[1];
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let mut pos: Vec<usize> = vec![0; n];
    a.trim().split_whitespace().map(|s| s.parse::<usize>().unwrap()).enumerate().for_each(|pair| {
        pos[pair.0 + 1] = pos[pair.0] + pair.1;
    });
    let mut result: Vec<usize> = vec![0; n];
    pos.iter().enumerate().for_each(|pair| {
        if pair.0 > 0 {
            result[pair.0] = max(*pair.1, result[pair.0 - 1] + d);
        }
    });
    println!("{}", result.iter().map(|&i| i.to_string()).collect::<Vec<_>>().join(" "));
}
0