結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー kenkoooo
提出日時 2015-05-08 23:04:40
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 795 bytes
コンパイル時間 2,279 ms
コンパイル使用メモリ 76,552 KB
実行使用メモリ 42,180 KB
最終ジャッジ日時 2024-10-13 11:43:20
合計ジャッジ時間 10,942 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 33
権限があれば一括ダウンロードができます

ソースコード

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();
		sc.close();
		string = string.replaceAll("o", "1").replaceAll("x", "0");

		int max = 0;
		for (int i = 0; i < (1 << 14); i++) {
			if ((i & Integer.parseInt(string, 2)) != 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