結果
問題 | No.342 一番ワロタww |
ユーザー | mitsuo |
提出日時 | 2016-05-09 22:59:59 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 122 ms / 5,000 ms |
コード長 | 1,080 bytes |
コンパイル時間 | 2,192 ms |
コンパイル使用メモリ | 78,972 KB |
実行使用メモリ | 54,356 KB |
最終ジャッジ日時 | 2024-04-23 13:24:56 |
合計ジャッジ時間 | 4,745 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 114 ms
54,072 KB |
testcase_01 | AC | 102 ms
54,032 KB |
testcase_02 | AC | 115 ms
53,916 KB |
testcase_03 | AC | 113 ms
54,168 KB |
testcase_04 | AC | 104 ms
53,108 KB |
testcase_05 | AC | 114 ms
53,684 KB |
testcase_06 | AC | 114 ms
54,356 KB |
testcase_07 | AC | 108 ms
52,792 KB |
testcase_08 | AC | 111 ms
53,100 KB |
testcase_09 | AC | 116 ms
54,100 KB |
testcase_10 | AC | 114 ms
53,800 KB |
testcase_11 | AC | 122 ms
53,984 KB |
testcase_12 | AC | 100 ms
52,516 KB |
testcase_13 | AC | 109 ms
53,700 KB |
testcase_14 | AC | 111 ms
54,100 KB |
testcase_15 | AC | 115 ms
54,064 KB |
testcase_16 | AC | 114 ms
54,092 KB |
ソースコード
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(); } }