結果
問題 |
No.204 ゴールデン・ウィーク(2)
|
ユーザー |
![]() |
提出日時 | 2015-05-09 00:06:58 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,634 bytes |
コンパイル時間 | 2,089 ms |
コンパイル使用メモリ | 79,896 KB |
実行使用メモリ | 55,128 KB |
最終ジャッジ日時 | 2024-10-13 11:58:13 |
合計ジャッジ時間 | 10,504 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 WA * 4 RE * 2 |
ソースコード
import java.util.*; class Ideone{ public static void main (String[] args) throws java.lang.Exception { Scanner koko = new Scanner(System.in); int d = koko.nextInt(); String one = koko.next(); String two = koko.next(); String whole = "xxxxxxxxxxxxxx" + one + two + "xxxxxxxxxxxxxx"; if(whole.equals("xxxxxxxxxxxxxxxxxxxxxxxxxxxx")){ System.out.println(d); }else{ String[] on = whole.split("o+"); int[] onseq = new int[on.length]; int counton = 0; int countoff = 0; int onp =0; int offp =0; for(int i=0; i<on.length; i++){ if(on[i].length()!=0){ onseq[onp++]=on[i].length(); counton++; } } String[] off = whole.split("x+"); int[] offseq = new int[off.length]; for(int i=0; i<off.length; i++){ if(off[i].length()!=0){ offseq[offp++]=off[i].length(); countoff++; } } int max=0; if(onseq[0]<=d){ max=onseq[0]+offseq[0]; } if(countoff==1){ if(on[1].length()<=d){ max=Math.max(max, offseq[0]+onseq[1]); }else{ max=Math.max(max, offseq[0]+d); } }else{ for(int i=1; i<counton-1; i++){ if(onseq[i]<=d){ max=Math.max(max, offseq[i-1]+onseq[i]+offseq[i]); }else{ max=Math.max(max, offseq[i-1]+d); max=Math.max(max, offseq[i]+d); } } max=Math.max(max, offseq[countoff-1]+Math.min(d, onseq[counton-1])); } System.out.println(max); } } }