結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー tonyu0tonyu0
提出日時 2020-04-26 16:29:20
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,532 bytes
コンパイル時間 2,468 ms
コンパイル使用メモリ 141,320 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-11 00:24:29
合計ジャッジ時間 3,023 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
4,376 KB
testcase_23 WA -
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,384 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 0 ms
4,376 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)));
}
0