結果

問題 No.342 一番ワロタww
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-02-13 05:46:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 1,213 bytes
コンパイル時間 2,670 ms
コンパイル使用メモリ 77,748 KB
実行使用メモリ 42,020 KB
最終ジャッジ日時 2024-04-23 13:21:13
合計ジャッジ時間 5,671 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
41,412 KB
testcase_01 AC 112 ms
41,356 KB
testcase_02 AC 100 ms
41,368 KB
testcase_03 AC 100 ms
41,384 KB
testcase_04 AC 114 ms
41,160 KB
testcase_05 AC 106 ms
41,472 KB
testcase_06 AC 112 ms
41,372 KB
testcase_07 AC 115 ms
41,588 KB
testcase_08 AC 105 ms
41,604 KB
testcase_09 AC 116 ms
41,500 KB
testcase_10 AC 115 ms
41,508 KB
testcase_11 AC 113 ms
42,020 KB
testcase_12 AC 117 ms
41,596 KB
testcase_13 AC 115 ms
41,432 KB
testcase_14 AC 119 ms
42,016 KB
testcase_15 AC 105 ms
41,288 KB
testcase_16 AC 118 ms
41,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        int n = s.length();
        in.close();

        ArrayList<String> str = new ArrayList<String>();
        ArrayList<Integer> len = new ArrayList<Integer>();

        int max = 0;
        int i = 0;
        while(i < n) {
            int j = s.indexOf('w', i);
            if(j == -1) {
                break;
            } else if(j == 0) {
            } else {
                str.add(s.substring(i, j));
                i = j;
            }

            int temp = 0;
            while(i < n && s.charAt(i) == 'w') {
                temp++;
                i++;
            }
            if(j > 0) {
                len.add(temp);
                max = Math.max(max, temp);
            }
        }

        if(str.size() == 0) {
            System.out.println();
        } else {
            for(int j=0; j<str.size(); j++) {
                if(len.get(j) == max) {
                    System.out.println(str.get(j));
                }
            }
        }
    }
}
0