結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
Maricom_tkg
|
| 提出日時 | 2018-11-03 17:03:58 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 787 bytes |
| コンパイル時間 | 14,214 ms |
| コンパイル使用メモリ | 402,940 KB |
| 実行使用メモリ | 15,680 KB |
| 最終ジャッジ日時 | 2024-11-20 19:18:48 |
| 合計ジャッジ時間 | 179,221 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 4 TLE * 26 |
ソースコード
use std::io::Read;
use std::cmp;
fn main() {
let mut buf = String::new();
std::io::stdin().read_to_string(&mut buf).unwrap();
let mut iter = buf.split_whitespace();
let n: usize = iter.next().unwrap().parse().unwrap();
let sushi_lane: Vec<usize> = iter
.map(|v| v.parse::<usize>().unwrap())
.collect();
println!("{}", calc_max(&sushi_lane, 0, n-1));
}
fn calc_max(sushi_lane: &Vec<usize>, pos: usize, tail: usize) -> usize {
if pos == tail {
return sushi_lane[tail]
} else if pos > tail {
return 0
}
let left_max: usize = sushi_lane[pos] + calc_max(sushi_lane, pos+2, tail);
let right_max: usize = sushi_lane[pos+1] + calc_max(sushi_lane, pos+3, tail);
cmp::max(left_max, right_max)
}
Maricom_tkg