結果
| 問題 | No.204 ゴールデン・ウィーク(2) |
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2020-05-08 11:01:14 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 1,000 ms |
| コード長 | 1,010 bytes |
| 記録 | |
| コンパイル時間 | 1,543 ms |
| コンパイル使用メモリ | 82,880 KB |
| 実行使用メモリ | 41,856 KB |
| 最終ジャッジ日時 | 2026-03-24 18:00:38 |
| 合計ジャッジ時間 | 5,497 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 46 |
ソースコード
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;
}
}
htensai