結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー htensai
提出日時 2020-05-08 11:01:14
言語 Java
(openjdk 23)
結果
AC  
実行時間 136 ms / 1,000 ms
コード長 1,010 bytes
コンパイル時間 2,239 ms
コンパイル使用メモリ 77,292 KB
実行使用メモリ 52,164 KB
最終ジャッジ日時 2024-07-03 09:48:35
合計ジャッジ時間 10,232 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

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