結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー uafr_csuafr_cs
提出日時 2015-06-20 02:08:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 1,000 ms
コード長 1,358 bytes
コンパイル時間 4,207 ms
コンパイル使用メモリ 79,028 KB
実行使用メモリ 56,352 KB
最終ジャッジ日時 2023-08-25 23:44:21
合計ジャッジ時間 10,908 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,916 KB
testcase_01 AC 127 ms
55,904 KB
testcase_02 AC 128 ms
55,576 KB
testcase_03 AC 129 ms
55,436 KB
testcase_04 AC 127 ms
55,560 KB
testcase_05 AC 127 ms
55,596 KB
testcase_06 AC 127 ms
55,564 KB
testcase_07 AC 129 ms
55,972 KB
testcase_08 AC 129 ms
55,600 KB
testcase_09 AC 126 ms
55,444 KB
testcase_10 AC 127 ms
55,384 KB
testcase_11 AC 126 ms
56,088 KB
testcase_12 AC 127 ms
55,716 KB
testcase_13 AC 127 ms
55,652 KB
testcase_14 AC 127 ms
55,644 KB
testcase_15 AC 125 ms
55,704 KB
testcase_16 AC 125 ms
55,620 KB
testcase_17 AC 126 ms
55,612 KB
testcase_18 AC 129 ms
55,592 KB
testcase_19 AC 127 ms
55,704 KB
testcase_20 AC 127 ms
55,756 KB
testcase_21 AC 125 ms
55,616 KB
testcase_22 AC 127 ms
55,604 KB
testcase_23 AC 128 ms
55,888 KB
testcase_24 AC 128 ms
55,644 KB
testcase_25 AC 126 ms
55,360 KB
testcase_26 AC 124 ms
55,676 KB
testcase_27 AC 125 ms
55,688 KB
testcase_28 AC 126 ms
55,612 KB
testcase_29 AC 128 ms
55,972 KB
testcase_30 AC 127 ms
55,748 KB
testcase_31 AC 126 ms
55,688 KB
testcase_32 AC 127 ms
55,448 KB
testcase_33 AC 127 ms
55,780 KB
testcase_34 AC 126 ms
55,820 KB
testcase_35 AC 126 ms
55,712 KB
testcase_36 AC 127 ms
55,824 KB
testcase_37 AC 127 ms
55,840 KB
testcase_38 AC 127 ms
55,696 KB
testcase_39 AC 125 ms
56,352 KB
testcase_40 AC 125 ms
55,608 KB
testcase_41 AC 126 ms
53,468 KB
testcase_42 AC 126 ms
55,916 KB
testcase_43 AC 126 ms
55,800 KB
testcase_44 AC 127 ms
55,552 KB
testcase_45 AC 127 ms
55,612 KB
testcase_46 AC 126 ms
55,864 KB
testcase_47 AC 128 ms
55,440 KB
testcase_48 AC 127 ms
55,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public static final int SIZE = 14;

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

		final int D = sc.nextInt();

		boolean[] days = new boolean[SIZE];
		for (int i = 0; i < 2; i++) {
			char[] inputs = sc.next().toCharArray();

			for (int j = 0; j < SIZE / 2; j++) {
				days[i * (SIZE / 2) + j] = inputs[j] == 'o';
			}
		}

		int max = 0;
		for (int d = 0; d <= D; d++) {
			POS:
			for (int start = 0; start <= 3 * SIZE - D; start++) {
				boolean[] new_days = new boolean[3 * SIZE];
				System.arraycopy(days, 0, new_days, SIZE, SIZE);
				
				for(int i = 0; i < d; i++){
					if(new_days[start + i]){
						continue POS;
					}
				}
				
				for (int i = 0; i < d; i++) {
					new_days[start + i] = true;
				}

				int prev = -1;
				for (int cur = 0; cur < new_days.length; cur++) {
					if (!new_days[cur] && prev >= 0) {
						max = Math.max(max, cur - prev);
						prev = -1;
					}

					if (new_days[cur] && prev < 0) {
						prev = cur;
					}
				}

				if (prev >= 0) {
					max = Math.max(max, new_days.length - prev);
				}
			}
		}

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