結果

問題 No.342 一番ワロタww
ユーザー mitsuomitsuo
提出日時 2016-05-09 22:59:59
言語 Java19
(openjdk 21)
結果
AC  
実行時間 116 ms / 5,000 ms
コード長 1,080 bytes
コンパイル時間 1,934 ms
コンパイル使用メモリ 75,856 KB
実行使用メモリ 56,216 KB
最終ジャッジ日時 2023-08-05 16:17:05
合計ジャッジ時間 4,687 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
55,712 KB
testcase_01 AC 109 ms
56,216 KB
testcase_02 AC 112 ms
55,528 KB
testcase_03 AC 109 ms
55,832 KB
testcase_04 AC 110 ms
56,000 KB
testcase_05 AC 107 ms
56,184 KB
testcase_06 AC 106 ms
55,656 KB
testcase_07 AC 107 ms
55,888 KB
testcase_08 AC 116 ms
56,068 KB
testcase_09 AC 107 ms
55,620 KB
testcase_10 AC 110 ms
56,204 KB
testcase_11 AC 106 ms
55,628 KB
testcase_12 AC 109 ms
55,776 KB
testcase_13 AC 108 ms
55,684 KB
testcase_14 AC 110 ms
55,532 KB
testcase_15 AC 104 ms
55,480 KB
testcase_16 AC 108 ms
55,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package jp.fedom.challange.yuki.l2.q342;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> input = new ArrayList<>();
		while (sc.hasNext()) {
			input.add(sc.nextLine());
		}

		System.out.println(solve(input));

		sc.close();
	}

	public static String solve(List<String> in) {
		String S = in.get(0);
		Pattern p = Pattern.compile("([^w]+)(w+)");
		Matcher m = p.matcher(S);

		StringBuilder sb = new StringBuilder();
		String d = System.lineSeparator();
		int max = 0;
		
		while (m.find()) {
			if (m.groupCount() == 2) {
				if (max == m.group(0).length() - m.group(1).length()) {
					sb.append(m.group(1)).append(d);
				} else if (max < m.group(0).length() - m.group(1).length()) {
					sb = new StringBuilder();
					sb.append(m.group(1)).append(d);
					max = m.group(0).length() - m.group(1).length();
				}
			}
		}

		return sb.toString().trim();
	}

}
0