結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー kenkoooo
提出日時 2015-05-09 00:34:49
言語 Java
(openjdk 23)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,108 bytes
コンパイル時間 5,189 ms
コンパイル使用メモリ 78,672 KB
実行使用メモリ 55,168 KB
最終ジャッジ日時 2024-10-15 17:25:58
合計ジャッジ時間 14,698 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 45 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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 day = 0; day <= D; day++) {
			slide: for (int i = 0; i + day < 42; i++) {
				char[] holidays = new char[42];
				for (int j = 0; j < 42; j++) {
					if (j < i) {
						if (string[j] == 'o') {
							holidays[j] = 'o';
						} else {
							holidays[j] = 'x';
						}
					} else if (j < i + day) {
						if (string[j] == 'o') {
							continue slide;
						} else {
							holidays[j] = 'o';
						}
					} else {
						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