結果

問題 No.1090 ソーシャルディスタンス / Social Distance
ユーザー ikdikd
提出日時 2020-07-20 01:00:11
言語 Rust
(1.77.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 748 bytes
コンパイル時間 12,862 ms
コンパイル使用メモリ 395,264 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-05-10 01:33:45
合計ジャッジ時間 16,566 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 20 ms
6,944 KB
testcase_03 AC 4 ms
6,940 KB
testcase_04 AC 22 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 27 ms
7,808 KB
testcase_07 AC 14 ms
6,944 KB
testcase_08 AC 28 ms
8,192 KB
testcase_09 AC 15 ms
6,944 KB
testcase_10 AC 19 ms
6,940 KB
testcase_11 AC 29 ms
8,576 KB
testcase_12 AC 16 ms
6,944 KB
testcase_13 AC 16 ms
6,944 KB
testcase_14 AC 26 ms
7,808 KB
testcase_15 AC 21 ms
6,940 KB
testcase_16 AC 10 ms
6,944 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 10 ms
6,940 KB
testcase_19 AC 14 ms
6,940 KB
testcase_20 AC 12 ms
6,944 KB
testcase_21 AC 16 ms
6,944 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 33 ms
8,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn read<T: std::str::FromStr>() -> T {
    let token: String = std::io::stdin()
        .bytes()
        .map(|c| c.ok().unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i32 = read();
    let d: i32 = read();
    let mut s: i32 = 0;
    let mut v = Vec::new();
    v.push(0);
    for _ in 2..=n {
        let a: i32 = read();
        s += a;
        let &last = v.last().unwrap();
        if s - last < d {
            v.push(last + d);
        } else {
            v.push(s);
        }
    }
    let ans: Vec<_> = v.iter().map(|x| x.to_string()).collect();
    println!("{}", ans.join(" "));
}
0