結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-05-22 01:41:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 1,000 ms
コード長 1,612 bytes
コンパイル時間 3,792 ms
コンパイル使用メモリ 79,360 KB
実行使用メモリ 57,480 KB
最終ジャッジ日時 2023-08-25 23:43:18
合計ジャッジ時間 11,650 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
56,544 KB
testcase_01 AC 138 ms
56,432 KB
testcase_02 AC 143 ms
56,808 KB
testcase_03 AC 143 ms
57,248 KB
testcase_04 AC 139 ms
56,796 KB
testcase_05 AC 143 ms
57,024 KB
testcase_06 AC 139 ms
56,808 KB
testcase_07 AC 139 ms
56,560 KB
testcase_08 AC 143 ms
57,156 KB
testcase_09 AC 142 ms
56,900 KB
testcase_10 AC 139 ms
56,536 KB
testcase_11 AC 143 ms
56,636 KB
testcase_12 AC 145 ms
56,636 KB
testcase_13 AC 144 ms
57,012 KB
testcase_14 AC 140 ms
57,012 KB
testcase_15 AC 138 ms
56,936 KB
testcase_16 AC 142 ms
57,008 KB
testcase_17 AC 139 ms
56,880 KB
testcase_18 AC 141 ms
56,804 KB
testcase_19 AC 139 ms
56,732 KB
testcase_20 AC 142 ms
56,712 KB
testcase_21 AC 146 ms
56,784 KB
testcase_22 AC 146 ms
56,644 KB
testcase_23 AC 139 ms
56,468 KB
testcase_24 AC 140 ms
57,028 KB
testcase_25 AC 139 ms
56,936 KB
testcase_26 AC 141 ms
57,004 KB
testcase_27 AC 137 ms
56,624 KB
testcase_28 AC 138 ms
56,900 KB
testcase_29 AC 139 ms
56,704 KB
testcase_30 AC 139 ms
56,940 KB
testcase_31 AC 146 ms
56,868 KB
testcase_32 AC 148 ms
57,220 KB
testcase_33 AC 148 ms
56,796 KB
testcase_34 AC 141 ms
56,888 KB
testcase_35 AC 138 ms
57,068 KB
testcase_36 AC 141 ms
56,712 KB
testcase_37 AC 143 ms
56,744 KB
testcase_38 AC 142 ms
56,544 KB
testcase_39 AC 143 ms
56,856 KB
testcase_40 AC 135 ms
56,644 KB
testcase_41 AC 137 ms
57,024 KB
testcase_42 AC 142 ms
56,904 KB
testcase_43 AC 140 ms
56,668 KB
testcase_44 AC 133 ms
57,176 KB
testcase_45 AC 137 ms
56,804 KB
testcase_46 AC 142 ms
57,480 KB
testcase_47 AC 141 ms
57,064 KB
testcase_48 AC 144 ms
56,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class No0204 {
    
    static final Scanner in = new Scanner(System.in);
    static final PrintWriter out = new PrintWriter(System.out,false);

    static void solve() {
        int d = in.nextInt();
        String s = in.next();
        String t = in.next();
        String x = "xxxxxxxxxxxxxx";
        s = x + s + t + x;
        char[] cs = s.toCharArray();


        int res = 0;
        for (int i=0; i<cs.length; i++) {
            char[] clone = cs.clone();

            for (int j=i; j-i<d && j<cs.length; j++) {
                if (j < cs.length-1 && clone[j] == 'x' && clone[j+1] == 'o') {
                    clone[j] = 'o';
                    break;
                }
                clone[j] = 'o';
            }

            res = max(res,count(clone));
        }

        out.println(res);
    }

    static int count(char[] cs) {
        int res = 0;
        for (int i=1; i<cs.length; i++) {
            if (cs[i] == 'x') continue;
            int cnt = 1;
            while (i < cs.length && cs[i] == cs[i-1]) {
                cnt++;
                i++;
            }
            res = max(res,cnt);
        }

        return res;
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();

        solve();
        out.flush();

        long end = System.currentTimeMillis();
        //trace(end-start + "ms");
        in.close();
        out.close();
    }

    static void trace(Object... o) { System.out.println(deepToString(o));}
}
0