結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー chiho_miyakochiho_miyako
提出日時 2015-05-09 00:09:43
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,648 bytes
コンパイル時間 1,993 ms
コンパイル使用メモリ 79,796 KB
実行使用メモリ 58,660 KB
最終ジャッジ日時 2024-04-21 13:22:33
合計ジャッジ時間 9,559 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
42,012 KB
testcase_01 AC 119 ms
42,240 KB
testcase_02 AC 128 ms
42,140 KB
testcase_03 AC 133 ms
42,184 KB
testcase_04 AC 131 ms
42,128 KB
testcase_05 AC 128 ms
42,548 KB
testcase_06 AC 126 ms
42,452 KB
testcase_07 AC 132 ms
42,292 KB
testcase_08 AC 139 ms
42,344 KB
testcase_09 WA -
testcase_10 AC 122 ms
41,992 KB
testcase_11 AC 119 ms
42,220 KB
testcase_12 AC 115 ms
42,548 KB
testcase_13 WA -
testcase_14 AC 120 ms
42,388 KB
testcase_15 AC 119 ms
42,164 KB
testcase_16 AC 142 ms
42,496 KB
testcase_17 AC 139 ms
42,624 KB
testcase_18 WA -
testcase_19 AC 123 ms
42,300 KB
testcase_20 WA -
testcase_21 AC 120 ms
41,968 KB
testcase_22 AC 120 ms
42,520 KB
testcase_23 AC 132 ms
42,296 KB
testcase_24 AC 135 ms
42,156 KB
testcase_25 AC 140 ms
42,284 KB
testcase_26 AC 123 ms
42,428 KB
testcase_27 AC 141 ms
42,496 KB
testcase_28 AC 120 ms
42,316 KB
testcase_29 AC 140 ms
42,340 KB
testcase_30 AC 134 ms
42,160 KB
testcase_31 AC 130 ms
42,528 KB
testcase_32 AC 128 ms
42,156 KB
testcase_33 AC 133 ms
42,184 KB
testcase_34 AC 135 ms
42,496 KB
testcase_35 AC 131 ms
42,180 KB
testcase_36 AC 130 ms
42,584 KB
testcase_37 AC 129 ms
42,456 KB
testcase_38 AC 121 ms
42,252 KB
testcase_39 AC 135 ms
42,396 KB
testcase_40 AC 138 ms
42,600 KB
testcase_41 AC 130 ms
42,136 KB
testcase_42 AC 129 ms
42,316 KB
testcase_43 AC 138 ms
42,620 KB
testcase_44 AC 141 ms
42,132 KB
testcase_45 AC 136 ms
42,608 KB
testcase_46 AC 142 ms
42,228 KB
testcase_47 AC 134 ms
42,392 KB
testcase_48 AC 143 ms
42,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")){
        	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);
        
    }
    }
}
0