結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー htensaihtensai
提出日時 2020-05-08 11:01:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 1,000 ms
コード長 1,010 bytes
コンパイル時間 2,719 ms
コンパイル使用メモリ 74,920 KB
実行使用メモリ 58,148 KB
最終ジャッジ日時 2023-09-16 08:23:38
合計ジャッジ時間 10,429 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,292 KB
testcase_01 AC 123 ms
56,080 KB
testcase_02 AC 121 ms
56,180 KB
testcase_03 AC 122 ms
56,336 KB
testcase_04 AC 122 ms
55,772 KB
testcase_05 AC 121 ms
55,836 KB
testcase_06 AC 119 ms
55,904 KB
testcase_07 AC 119 ms
55,556 KB
testcase_08 AC 121 ms
56,004 KB
testcase_09 AC 121 ms
55,768 KB
testcase_10 AC 121 ms
56,008 KB
testcase_11 AC 124 ms
55,992 KB
testcase_12 AC 125 ms
55,824 KB
testcase_13 AC 120 ms
55,820 KB
testcase_14 AC 120 ms
55,736 KB
testcase_15 AC 124 ms
56,024 KB
testcase_16 AC 121 ms
53,676 KB
testcase_17 AC 121 ms
54,576 KB
testcase_18 AC 121 ms
55,828 KB
testcase_19 AC 121 ms
55,876 KB
testcase_20 AC 122 ms
55,848 KB
testcase_21 AC 120 ms
55,988 KB
testcase_22 AC 119 ms
56,276 KB
testcase_23 AC 121 ms
56,416 KB
testcase_24 AC 119 ms
56,020 KB
testcase_25 AC 121 ms
55,744 KB
testcase_26 AC 121 ms
55,596 KB
testcase_27 AC 121 ms
55,844 KB
testcase_28 AC 122 ms
56,088 KB
testcase_29 AC 119 ms
55,896 KB
testcase_30 AC 119 ms
55,972 KB
testcase_31 AC 119 ms
57,804 KB
testcase_32 AC 119 ms
55,784 KB
testcase_33 AC 120 ms
56,152 KB
testcase_34 AC 120 ms
55,848 KB
testcase_35 AC 119 ms
56,364 KB
testcase_36 AC 119 ms
56,228 KB
testcase_37 AC 120 ms
55,996 KB
testcase_38 AC 120 ms
55,764 KB
testcase_39 AC 120 ms
55,852 KB
testcase_40 AC 120 ms
55,764 KB
testcase_41 AC 120 ms
58,148 KB
testcase_42 AC 121 ms
56,212 KB
testcase_43 AC 122 ms
55,964 KB
testcase_44 AC 121 ms
55,924 KB
testcase_45 AC 120 ms
55,972 KB
testcase_46 AC 120 ms
56,048 KB
testcase_47 AC 122 ms
55,860 KB
testcase_48 AC 121 ms
56,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		boolean[] days = new boolean[14 * 3];
		char[] first = sc.next().toCharArray();
		for (int i = 0; i < 7; i++) {
		    days[i + 14] = (first[i] == 'o');
		}
		char[] second = sc.next().toCharArray();
		for (int i = 0; i < 7; i++) {
		    days[i + 21] = (second[i] == 'o');
		}
		int max = getLength(days);
		for (int i = 0; i < days.length; i++) {
		    boolean[] tmp = (boolean[])(days.clone());
		    for (int j = 0; j < d && i + j < days.length && !tmp[i + j]; j++) {
		        tmp[i + j] = true;
		    }
		    max = Math.max(max, getLength(tmp));
		}
		System.out.println(max);
	}
	
	static int getLength(boolean[] days) {
	    int max = 0;
	    int length = 0;
	    for (boolean b : days) {
	        if (b) {
	            length++;
	            max = Math.max(max, length);
	        } else {
	            length = 0;
	        }
	    }
	    return max;
	}
}
0