結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー Grenache
提出日時 2015-05-08 23:33:17
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 824 bytes
コンパイル時間 1,971 ms
コンパイル使用メモリ 79,628 KB
実行使用メモリ 56,796 KB
最終ジャッジ日時 2024-10-13 11:54:19
合計ジャッジ時間 10,339 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder150508;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int d = sc.nextInt();
		String c = "xxxxxxx" + sc.next() + sc.next() + "xxxxxxx";
		StringBuffer[] cc = new StringBuffer[c.length()];

		for (int i = 0; i < c.length(); i++) {
			cc[i] = new StringBuffer(c);
			for (int j = i; j < i + d && j < cc[i].length(); j++) {
				if (cc[i].charAt(j) == 'x') {
					cc[i].setCharAt(j, 'o');
				} else {
					break;
				}
			}
		}
		
		int max = 0;
		for (int j = 0; j < cc.length; j++) {
			int count = 0;
			for (int i = 0; i < cc[j].length(); i++) {
				if (cc[j].charAt(i) == 'o') {
					count++;
					max = Math.max(max, count);
				} else {
					count = 0;
				}
			}
		}

		System.out.println(max);

		sc.close();
	}
}
0