結果
問題 |
No.204 ゴールデン・ウィーク(2)
|
ユーザー |
|
提出日時 | 2020-04-26 16:29:20 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,532 bytes |
コンパイル時間 | 14,088 ms |
コンパイル使用メモリ | 388,072 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-17 11:29:33 |
合計ジャッジ時間 | 15,813 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 WA * 15 |
ソースコード
use std::cmp::max; use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let s: Vec<char> = itr.next().unwrap().chars().collect(); let t: Vec<char> = itr.next().unwrap().chars().collect(); let mut week = Vec::new(); for i in 0..7 { week.push(s[i] == 'o'); } for i in 0..7 { week.push(t[i] == 'o'); } let mut ans = 0; for i in 0..14 { let mut cnt = 0; let mut u = week.clone(); let mut j = i; let mut un = false; while j < 14 { if !u[j] { un = true; if cnt == n { break; } cnt += 1; u[j] = true; } else if un { break; } j += 1 } cnt = 0; for j in 0..14 { if u[j] { cnt += 1; } else { ans = std::cmp::max(ans, cnt); cnt = 0; } } ans = std::cmp::max(ans, cnt); } let mut atama = 0; let mut oshiri = 0; let mut idx = 0; while idx < 14 && week[idx] { atama += 1; idx += 1 } week.reverse(); idx = 0; while idx < 14 && week[idx] { oshiri += 1; idx += 1 } println!("{}", max(ans, max(atama + n, oshiri + n))); }