結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー noriocnorioc
提出日時 2017-08-12 04:08:28
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,173 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 96,348 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-03 15:50:08
合計ジャッジ時間 3,286 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

int calc(int d, string s) {
    // 平日=0, 休日=1
    int[] ss = s.map!(e => e == 'x' ? 0 : 1).array;

    auto as = 0.repeat().take(d).array;
    auto xs = as ~ ss ~ as; // 2 週間の前後を挟む

    int ans = 0;
    for (int i = 0; i < xs.length - d; i++) { // i 日目から連続で d 日休暇
        auto ys = xs.dup;

        for (int j = i; j < i + d; j++) { // i 日目から d 日休暇
            if (ys[j] == 1) // 休日はまたがない
                break;
            ys[j] = 1;
        }

        int holidays = 0;
        for (int j = 0; j < xs.length; j++) {
            if (ys[j] == 1) {
                holidays++;
                ans = max(ans, holidays);
            }
            else {
                holidays = 0;
            }
        }
    }
    return ans;
}

void main() {
    int d = readint();
    auto s = readln.chomp;
    auto t = readln.chomp;
    writeln(calc(d, s ~ t));
}
0