結果

問題 No.342 一番ワロタww
ユーザー YamaKasaYamaKasa
提出日時 2018-09-16 22:16:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 1,448 bytes
コンパイル時間 2,303 ms
コンパイル使用メモリ 76,540 KB
実行使用メモリ 56,328 KB
最終ジャッジ日時 2023-09-25 09:11:39
合計ジャッジ時間 5,288 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,108 KB
testcase_01 AC 120 ms
56,112 KB
testcase_02 AC 119 ms
55,640 KB
testcase_03 AC 122 ms
55,900 KB
testcase_04 AC 124 ms
55,944 KB
testcase_05 AC 127 ms
55,704 KB
testcase_06 AC 125 ms
56,260 KB
testcase_07 AC 124 ms
55,996 KB
testcase_08 AC 123 ms
56,164 KB
testcase_09 AC 123 ms
55,924 KB
testcase_10 AC 120 ms
55,840 KB
testcase_11 AC 121 ms
55,956 KB
testcase_12 AC 119 ms
55,820 KB
testcase_13 AC 122 ms
56,328 KB
testcase_14 AC 122 ms
55,568 KB
testcase_15 AC 126 ms
55,860 KB
testcase_16 AC 120 ms
55,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.nextLine();
		scan.close();
		if(S.substring(0, 1).equals("w")) {
			for(int i = 0; i < S.length(); i++) {
				if(S.substring(i, i + 1).equals("w")) {
					continue;
				}else {
					S = S.substring(i, S.length());
					break;
				}
			}
		}
		S = S + " ";
		String []ary = new String[S.length()];
		for(int i = 0; i < S.length(); i++) {
			ary[i] = S.substring(i, i + 1);
		}
		int l = ary.length;
		int max = 0;
		List<Data>list = new  ArrayList<Data>();
		int begin = 0;
		for(int i = 0; i < l; i++) {
			if(ary[i].equals("w")) {
				int cnt = 1;
				int t = i;
				i++;
				while(i < l) {
					if(ary[i].equals("w")) {
						cnt ++;
						i++;
						continue;
					}else {
						String s = S.substring(begin, t);
						begin = i;
						Data d = new Data(s, cnt);
						list.add(d);
						if(max < cnt) {
							max = cnt;
						}
						break;
					}
				}
			}
		}
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < list.size(); i++) {
			if(list.get(i).getN() == max) {
				sb.append(list.get(i).getS()).append("\n");
			}
		}
		System.out.print(sb.toString());
	}
}

class Data{
	String s;
	int n;
	public Data(String s, int n) {
		this.s = s;
		this.n = n;
	}
	String getS() {
		return s;
	}
	int getN() {
		return n;
	}
}
0