結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー kenkoooo
提出日時 2015-05-09 00:12:33
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 956 bytes
コンパイル時間 3,468 ms
コンパイル使用メモリ 79,296 KB
実行使用メモリ 56,820 KB
最終ジャッジ日時 2024-10-13 11:59:27
合計ジャッジ時間 11,531 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class CopyOfMain {

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

		int D = sc.nextInt();
		char[] string = ("xxxxxxxxxxxxxx" + sc.next() + sc.next() + "xxxxxxxxxxxxxx").toCharArray();
		sc.close();

		int max = 0;
		for (int i = 0; i + D < 56; i++) {
			char[] holidays = new char[56];
			for (int j = 0; j < i; j++) {
				if (string[j] == 'o') {
					holidays[j] = 'o';
				} else {
					holidays[j] = 'x';
				}
			}
			for (int j = i; j < i + D; j++) {
				holidays[j] = 'o';
			}
			for (int j = i + D; j < 56; j++) {
				if (string[j] == 'o') {
					holidays[j] = 'o';
				} else {
					holidays[j] = 'x';
				}
			}

			int cnt = 0;
			for (int j = 0; j < holidays.length; j++) {
				if (holidays[j] == 'o') {
					cnt++;
				}
				if (holidays[j] == 'x' || j == holidays.length - 1) {
					max = Math.max(max, cnt);
					cnt = 0;
				}
			}

		}

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