結果

問題 No.45 回転寿司
ユーザー ixTL255
提出日時 2023-01-05 10:27:39
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 0 ms / 5,000 ms
+ 875µs
コード長 438 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 502 ms
コンパイル使用メモリ 182,124 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-20 01:56:02
合計ジャッジ時間 2,826 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: value assigned to `c` is never read
  --> src/main.rs:10:21
   |
10 |     let (mut a, mut b, mut c) = (0usize, 0usize, 0usize);
   |                        ^^^^^ this value is reassigned later and never used
11 |     for i in v {
12 |         c = b + i;
   |         --------- `c` is overwritten here before the previous value is read
   |
   = note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default

ソースコード

diff #
raw source code

use std::io::Read;

fn main() {
	let mut s = String::new();
	std::io::stdin().read_to_string(&mut s).ok();
	let mut s = s.trim().split_whitespace();
	let _n: usize = s.next().unwrap().parse().unwrap();
	let v: Vec<usize> = s.map(|e| e.parse().unwrap()).collect();
	
	let (mut a, mut b, mut c) = (0usize, 0usize, 0usize);
	for i in v {
		c = b + i;
		b = if a > b { a } else { b };
		a = c;
	}
	println!("{}", if a > b { a } else { b });
}
0