結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー kenkooookenkoooo
提出日時 2015-05-08 23:00:09
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 816 bytes
コンパイル時間 3,913 ms
コンパイル使用メモリ 76,772 KB
実行使用メモリ 42,240 KB
最終ジャッジ日時 2024-04-21 13:07:49
合計ジャッジ時間 11,638 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 158 ms
41,476 KB
testcase_05 AC 159 ms
41,564 KB
testcase_06 AC 157 ms
41,512 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
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 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 144 ms
40,576 KB
testcase_30 AC 157 ms
41,544 KB
testcase_31 AC 159 ms
41,672 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 161 ms
41,600 KB
testcase_35 AC 162 ms
41,624 KB
testcase_36 AC 161 ms
41,460 KB
testcase_37 AC 159 ms
41,352 KB
testcase_38 AC 164 ms
41,396 KB
testcase_39 WA -
testcase_40 AC 160 ms
41,488 KB
testcase_41 AC 165 ms
41,524 KB
testcase_42 WA -
testcase_43 AC 144 ms
40,812 KB
testcase_44 AC 160 ms
41,444 KB
testcase_45 AC 158 ms
41,520 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		String string = sc.next() + sc.next();
		string = string.replaceAll("o", "1").replaceAll("x", "0");

		int max = 0;
		for (int i = 0; i < (1 << 14); i++) {
			if (Integer.bitCount(i & Integer.parseInt(string, 2)) != Integer.bitCount(Integer.parseInt(string, 2))) {
				continue;
			}
			if (Integer.bitCount(i) > Integer.bitCount(Integer.parseInt(string, 2)) + D) {
				continue;
			}

			char[] bits = ("0" + Integer.toBinaryString(i) + "0").toCharArray();
			int cnt = 0;
			for (int j = 0; j < bits.length; j++) {
				if (bits[j] == '1') {
					cnt++;
				} else {
					max = Math.max(max, cnt);
					cnt = 0;
				}
			}


		}
		System.out.println(max);
	}
}
0