結果
| 問題 | No.1090 ソーシャルディスタンス / Social Distance |
| ユーザー |
|
| 提出日時 | 2020-06-24 23:59:29 |
| 言語 | Rust (1.92.0 + proconio + num) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 2,000 ms |
| コード長 | 803 bytes |
| 記録 | |
| コンパイル時間 | 11,844 ms |
| コンパイル使用メモリ | 378,348 KB |
| 実行使用メモリ | 10,240 KB |
| 最終ジャッジ日時 | 2024-07-03 20:28:55 |
| 合計ジャッジ時間 | 13,486 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 |
ソースコード
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(" "));
}