結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー YamaKasaYamaKasa
提出日時 2018-08-17 23:00:28
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,214 bytes
コンパイル時間 5,630 ms
コンパイル使用メモリ 76,944 KB
実行使用メモリ 56,644 KB
最終ジャッジ日時 2024-04-19 07:21:56
合計ジャッジ時間 10,641 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,740 KB
testcase_01 AC 129 ms
41,868 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 128 ms
41,300 KB
testcase_05 AC 128 ms
41,552 KB
testcase_06 AC 115 ms
41,680 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 115 ms
41,072 KB
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
testcase_21 RE -
testcase_22 AC 124 ms
41,532 KB
testcase_23 RE -
testcase_24 AC 114 ms
41,712 KB
testcase_25 AC 125 ms
41,556 KB
testcase_26 AC 128 ms
41,288 KB
testcase_27 RE -
testcase_28 AC 121 ms
40,480 KB
testcase_29 AC 126 ms
41,812 KB
testcase_30 AC 126 ms
41,460 KB
testcase_31 RE -
testcase_32 AC 128 ms
41,552 KB
testcase_33 AC 114 ms
40,404 KB
testcase_34 AC 126 ms
41,712 KB
testcase_35 AC 112 ms
40,332 KB
testcase_36 AC 121 ms
40,248 KB
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 AC 126 ms
41,220 KB
testcase_41 AC 124 ms
41,480 KB
testcase_42 AC 123 ms
41,268 KB
testcase_43 AC 112 ms
41,476 KB
testcase_44 AC 113 ms
41,496 KB
testcase_45 RE -
testcase_46 AC 124 ms
41,328 KB
testcase_47 AC 126 ms
41,408 KB
testcase_48 AC 126 ms
41,372 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 > 14) {
					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);
		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