結果
問題 | No.342 一番ワロタww |
ユーザー | jp_ste |
提出日時 | 2016-02-12 23:59:47 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 122 ms / 5,000 ms |
コード長 | 1,262 bytes |
コンパイル時間 | 3,252 ms |
コンパイル使用メモリ | 74,680 KB |
実行使用メモリ | 56,136 KB |
最終ジャッジ日時 | 2023-08-05 16:07:49 |
合計ジャッジ時間 | 6,164 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 116 ms
56,092 KB |
testcase_01 | AC | 117 ms
55,836 KB |
testcase_02 | AC | 117 ms
55,440 KB |
testcase_03 | AC | 115 ms
56,136 KB |
testcase_04 | AC | 119 ms
55,592 KB |
testcase_05 | AC | 119 ms
55,848 KB |
testcase_06 | AC | 117 ms
55,496 KB |
testcase_07 | AC | 120 ms
55,848 KB |
testcase_08 | AC | 117 ms
55,612 KB |
testcase_09 | AC | 118 ms
55,880 KB |
testcase_10 | AC | 115 ms
55,884 KB |
testcase_11 | AC | 119 ms
55,980 KB |
testcase_12 | AC | 117 ms
56,000 KB |
testcase_13 | AC | 122 ms
55,440 KB |
testcase_14 | AC | 117 ms
55,916 KB |
testcase_15 | AC | 120 ms
56,008 KB |
testcase_16 | AC | 116 ms
55,760 KB |
ソースコード
import java.util.ArrayList; import java.util.Scanner; public class No342 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String S = scan.nextLine(); scan.close(); int max = 0; ArrayList<Info> list = new ArrayList<>(); if(S.charAt(0) == 'w') { int count = 0; for(int i=0; i<S.length(); i++) { if(!(S.charAt(i) == 'w')) { break; } count++; } S = S.substring(count); } for(int i=0; i<S.length(); i++) { if(S.charAt(i) == 'w') { int count = 0; int index = i; int j; for(j=i; j<S.length(); j++) { if(!(S.charAt(j) == 'w')) { break; } count++; } i=j+1; list.add(new Info(index, count)); max = Math.max(max, count); } } if(list.size() == 0) { System.out.println(); } else { for(Info look : list) { if(look.length == max) { int first = 0; for(int i=look.index-1; i>=0; i--) { if(S.charAt(i) == 'w') { first = i+1; break; } } String ans = S.substring(first, look.index); System.out.println(ans); } } } } } class Info { int index; int length; Info(int index, int length) { this.index = index; this.length = length; } }