結果
| 問題 |
No.204 ゴールデン・ウィーク(2)
|
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2020-05-08 09:27:26 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 982 bytes |
| コンパイル時間 | 2,168 ms |
| コンパイル使用メモリ | 77,788 KB |
| 実行使用メモリ | 56,324 KB |
| 最終ジャッジ日時 | 2024-07-03 09:45:30 |
| 合計ジャッジ時間 | 9,835 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 25 |
ソースコード
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];
char[] first = sc.next().toCharArray();
for (int i = 0; i < 7; i++) {
days[i] = (first[i] == 'o');
}
char[] second = sc.next().toCharArray();
for (int i = 0; i < 7; i++) {
days[i + 7] = (second[i] == 'o');
}
int max = getLength(days);
for (int i = 0; i < 14; i++) {
boolean[] tmp = (boolean[])(days.clone());
for (int j = 0; j < d && i + j < 14 && !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