結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー YamaKasaYamaKasa
提出日時 2018-08-17 23:08:59
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,804 bytes
コンパイル時間 3,099 ms
コンパイル使用メモリ 77,256 KB
実行使用メモリ 41,760 KB
最終ジャッジ日時 2024-04-19 07:33:56
合計ジャッジ時間 9,744 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
41,176 KB
testcase_01 AC 130 ms
41,644 KB
testcase_02 AC 115 ms
40,140 KB
testcase_03 AC 130 ms
40,316 KB
testcase_04 AC 129 ms
41,436 KB
testcase_05 AC 113 ms
40,140 KB
testcase_06 AC 122 ms
40,440 KB
testcase_07 AC 114 ms
40,296 KB
testcase_08 AC 125 ms
41,100 KB
testcase_09 AC 134 ms
41,396 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 123 ms
41,056 KB
testcase_13 AC 128 ms
41,416 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 117 ms
40,868 KB
testcase_19 WA -
testcase_20 AC 123 ms
40,728 KB
testcase_21 AC 112 ms
40,320 KB
testcase_22 AC 122 ms
40,072 KB
testcase_23 WA -
testcase_24 AC 110 ms
40,320 KB
testcase_25 AC 113 ms
40,316 KB
testcase_26 AC 113 ms
40,392 KB
testcase_27 AC 128 ms
41,464 KB
testcase_28 WA -
testcase_29 AC 113 ms
40,324 KB
testcase_30 AC 126 ms
41,544 KB
testcase_31 AC 131 ms
41,356 KB
testcase_32 AC 126 ms
41,384 KB
testcase_33 AC 128 ms
41,260 KB
testcase_34 AC 114 ms
40,336 KB
testcase_35 AC 126 ms
41,456 KB
testcase_36 AC 126 ms
41,404 KB
testcase_37 AC 125 ms
41,612 KB
testcase_38 AC 116 ms
40,284 KB
testcase_39 AC 113 ms
40,208 KB
testcase_40 AC 125 ms
41,572 KB
testcase_41 AC 124 ms
41,256 KB
testcase_42 AC 131 ms
41,488 KB
testcase_43 AC 111 ms
39,996 KB
testcase_44 AC 122 ms
41,236 KB
testcase_45 AC 116 ms
40,008 KB
testcase_46 AC 126 ms
41,268 KB
testcase_47 AC 125 ms
41,204 KB
testcase_48 AC 125 ms
41,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int D = scan.nextInt();
		String C1 = scan.next();
		String C2 = scan.next();
		scan.close();
		char []c = new char[14];
		for(int i = 0; i < 7; i++) {
			c[i] = C1.charAt(i);
		}
		for(int i = 0; i < 7; i++) {
			c[i + 7] = C2.charAt(i);
		}
		int max = 0;
		for(int i = 0; i < 14; i++) {
			char []b = new char[14];
			for(int j = 0; j < 14; j++) {
				b[j] = c[j];
			}
			for(int j = i; j < i + D; j++) {
				if(j > 13) {
					break;
				}
				if(c[j] == 'x') {
					b[j] = 'o';
				}else {
					break;
				}
			}
			max = Math.max(max, solve(b));
		}
		int cnt1 = 0;
		for(int i = 0; i < 14; i++) {
			if(c[i] == 'o') {
				cnt1 ++;
			}else {
				break;
			}
		}
		int cnt2 = 0;
		for(int i = 13; i >= 0; i--) {
			if(c[i] == 'o') {
				cnt2++;
			}else {
				break;
			}
		}
		max = Math.max(max, cnt1 + D);
		max = Math.max(max, cnt2 + D);
		int cnt3 = 0;
		for(int i = 0; i < 14; i++) {
			if(c[i] == 'x') {
				cnt3 ++;
			}else {
				break;
			}
		}
		int cnt4 = 0;
		for(int i = 0; i < 14; i++) {
			if(c[i] == 'x') {
				cnt4 ++;
			}else {
				break;
			}
		}
		if(cnt3 <= D) {
			int cnt5 = 0;
			for(int i = cnt3; i < 14; i++) {
				if(c[i] == 'o') {
					cnt5++;
				}else {
					break;
				}
			}
			max = Math.max(max, D + cnt5);
		}
		if(cnt4 <= D) {
			int cnt6 = 0;
			for(int i = 13 - cnt4; i >= 0; i--) {
				if(c[i] == 'o') {
					cnt6++;
				}else {
					break;
				}
			}
			max = Math.max(max, D + cnt6);
		}
		System.out.println(max);
	}
	static int solve(char []c) {
		int k = 0;
		int max = 0;
		for(int i = 0; i < 14; i++) {
			if(c[i] == 'o') {
				k++;
			}else {
				k = 0;
			}
			if(max < k) {
				max = k;
			}
		}
		return max;
	}
}
0