結果
問題 | No.204 ゴールデン・ウィーク(2) |
ユーザー |
![]() |
提出日時 | 2016-01-30 14:16:19 |
言語 | Java (openjdk 23) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,782 bytes |
コンパイル時間 | 1,861 ms |
コンパイル使用メモリ | 77,424 KB |
実行使用メモリ | 50,544 KB |
最終ジャッジ日時 | 2024-10-13 13:52:39 |
合計ジャッジ時間 | 5,491 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 WA * 15 |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { static int D; public static void main(String[] args) { BufferedReader stdReader =new BufferedReader(new InputStreamReader(System.in)); boolean[] N = new boolean[14]; try { D = Integer.parseInt(stdReader.readLine()); String[] temp1 = stdReader.readLine().split(""); String[] temp2 = stdReader.readLine().split(""); int ans = 0; for(int i=0;i<7;i++) if(temp1[i].equals("o")) N[i] = true; for(int i=7;i<14;i++) if(temp2[i-7].equals("o")) N[i] = true; ans = calc(-1,N); for(int i=0;i<14;i++){ int count = 0; for(int j=0;j<D && i+j <14 ;j++){ if(!N[i+j]){ count++; N[i+j] = true; }else{ break; } } ans = Math.max(ans, calc(i,N)); for(int j=0;j<count;j++){ N[i+j] = false; } } System.out.println(ans); } catch (IOException e) { e.printStackTrace(); } } public static int calc(int num,boolean[] N){ int count = 0; int ans = 0; if(num==-1){ count = D; for(int i=0;i<N.length;i++){ if(N[i]){ count++; }else{ ans = Math.max(ans, count); count=0; } } ans = Math.max(ans, count); count = D; for(int i=N.length-1;i>=0;i--){ if(N[i]){ count++; }else{ ans = Math.max(ans, count); count=0; } } }else{ for(int i=0;i<N.length;i++){ if(N[i]){ count++; }else{ ans = Math.max(ans, count); count=0; } } ans = Math.max(ans, count); } return ans; } }