結果
問題 | No.2601 Very Poor |
ユーザー | 👑 H20 |
提出日時 | 2024-01-12 22:45:45 |
言語 | Rust (1.77.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,185 bytes |
コンパイル時間 | 2,128 ms |
コンパイル使用メモリ | 185,736 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-01-12 22:46:22 |
合計ジャッジ時間 | 3,681 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,676 KB |
testcase_01 | AC | 1 ms
6,676 KB |
testcase_02 | AC | 1 ms
6,676 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 1 ms
6,676 KB |
testcase_06 | AC | 1 ms
6,676 KB |
testcase_07 | AC | 1 ms
6,676 KB |
testcase_08 | AC | 1 ms
6,676 KB |
testcase_09 | AC | 1 ms
6,676 KB |
testcase_10 | AC | 1 ms
6,676 KB |
testcase_11 | AC | 1 ms
6,676 KB |
testcase_12 | AC | 1 ms
6,676 KB |
testcase_13 | AC | 1 ms
6,676 KB |
testcase_14 | AC | 1 ms
6,676 KB |
testcase_15 | AC | 17 ms
8,064 KB |
testcase_16 | AC | 17 ms
8,064 KB |
testcase_17 | AC | 17 ms
8,064 KB |
testcase_18 | AC | 17 ms
8,064 KB |
testcase_19 | AC | 17 ms
8,064 KB |
testcase_20 | AC | 18 ms
8,064 KB |
testcase_21 | AC | 17 ms
8,064 KB |
testcase_22 | AC | 17 ms
8,064 KB |
testcase_23 | AC | 17 ms
8,064 KB |
testcase_24 | AC | 17 ms
8,064 KB |
testcase_25 | AC | 17 ms
8,064 KB |
testcase_26 | AC | 17 ms
8,064 KB |
testcase_27 | AC | 17 ms
8,064 KB |
testcase_28 | AC | 18 ms
8,064 KB |
testcase_29 | AC | 17 ms
8,064 KB |
testcase_30 | AC | 17 ms
8,064 KB |
testcase_31 | AC | 17 ms
8,064 KB |
testcase_32 | AC | 17 ms
8,064 KB |
testcase_33 | AC | 25 ms
8,064 KB |
testcase_34 | AC | 16 ms
8,064 KB |
コンパイルメッセージ
warning: variable does not need to be mutable --> Main.rs:19:9 | 19 | let mut a: Vec<usize> = input | ----^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default warning: 1 warning emitted
ソースコード
use std::collections::VecDeque; use std::io; use std::str::FromStr; fn main() { let mut input = String::new(); io::stdin().read_line(&mut input).unwrap(); let parts: Vec<usize> = input .trim() .split_whitespace() .map(|x| usize::from_str(x).unwrap()) .collect(); let n = parts[0]; let _x = parts[1]; input.clear(); io::stdin().read_line(&mut input).unwrap(); let mut a: Vec<usize> = input .trim() .split_whitespace() .map(|x| usize::from_str(x).unwrap()) .collect(); // Aを連結する let mut extended_a = a.clone(); extended_a.extend(a); // Dequeの作成 let mut deque = VecDeque::new(); let mut total = 0; let mut ans = 0; for &item in &extended_a { deque.push_back(item); total += item; // 合計がxを超えたら先頭から要素を取り出す while total > _x && deque.len() <= n{ if let Some(front) = deque.pop_front() { total -= front; } } ans = std::cmp::max(ans,total); } // 最終的なDequeの内容を表示 println!("{}", ans); }