結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー jp_stejp_ste
提出日時 2016-05-12 02:14:46
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,288 bytes
コンパイル時間 1,982 ms
コンパイル使用メモリ 79,648 KB
実行使用メモリ 55,048 KB
最終ジャッジ日時 2024-04-21 15:13:28
合計ジャッジ時間 8,753 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
41,260 KB
testcase_01 AC 116 ms
41,308 KB
testcase_02 AC 107 ms
41,556 KB
testcase_03 AC 106 ms
41,016 KB
testcase_04 AC 111 ms
41,500 KB
testcase_05 AC 121 ms
40,988 KB
testcase_06 AC 117 ms
41,724 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 117 ms
41,496 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 117 ms
41,216 KB
testcase_23 WA -
testcase_24 AC 117 ms
41,384 KB
testcase_25 AC 114 ms
40,220 KB
testcase_26 AC 122 ms
41,124 KB
testcase_27 AC 118 ms
41,368 KB
testcase_28 AC 117 ms
41,192 KB
testcase_29 AC 99 ms
41,196 KB
testcase_30 AC 118 ms
41,244 KB
testcase_31 AC 102 ms
41,212 KB
testcase_32 AC 117 ms
41,216 KB
testcase_33 AC 118 ms
41,116 KB
testcase_34 AC 115 ms
40,108 KB
testcase_35 AC 117 ms
41,168 KB
testcase_36 AC 104 ms
41,068 KB
testcase_37 AC 107 ms
41,448 KB
testcase_38 AC 116 ms
41,020 KB
testcase_39 AC 114 ms
41,176 KB
testcase_40 AC 120 ms
41,060 KB
testcase_41 AC 100 ms
41,024 KB
testcase_42 AC 113 ms
41,016 KB
testcase_43 AC 115 ms
41,272 KB
testcase_44 AC 114 ms
41,264 KB
testcase_45 AC 112 ms
41,360 KB
testcase_46 AC 114 ms
40,972 KB
testcase_47 AC 98 ms
41,244 KB
testcase_48 AC 110 ms
41,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    static int max = 0;
    static int n;
    
    public static void main(String[] args) {
        try (Scanner scan = new Scanner(System.in)) {
            n = Integer.parseInt(scan.next());
            String str = scan.next() + scan.next();
            solve(str);
            solve(new StringBuffer(str).reverse().toString());
            System.out.println(max);
        }
    }
    
    static void solve(String str) {
        
        int count = 0;
        for(int i=0; i<str.length(); i++) {
            if(str.charAt(i) == 'o') {
                count++;
            } else {
                break;
            }
        }
        max = Math.max(max, count+n);
        
        count = 0;
        for(int i=str.length()-1; i>=0; i--) {
            if(str.charAt(i) == 'o') {
                count++;
            } else {
                break;
            }
        }
        max = Math.max(max, count+n);
        
        for(int i=0; i<str.length(); i++) {
            if(str.charAt(i) == 'o') {
                int count1 = 0;
                int j;
                for(j=i; j<str.length(); j++) {
                    if(str.charAt(j) == 'o') {
                        count1++;
                    } else {
                        break;
                    }
                }
                
                int count2 = 0;
                int k;
                for(k=j; k<str.length(); k++) {
                    if(str.charAt(k) == 'x') {
                        count2++;
                    } else {
                        break;
                    }
                }
                             
                if(count2 > n) { 
                    count2 = n;
                    max = Math.max(max, count1+count2);
                    
                } else {
                
                    int count3 = 0;
                    int l;
                    for(l=k; l<str.length(); l++) {
                        if(str.charAt(l) == 'o') {
                            count3++;
                        } else {
                            break;
                        }
                    }
                    max = Math.max(max, count1+count2+count3);
                }
            }
        }
    }
}
0