結果
問題 | No.342 一番ワロタww |
ユーザー | jp_ste |
提出日時 | 2016-02-12 23:59:47 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 134 ms / 5,000 ms |
コード長 | 1,262 bytes |
コンパイル時間 | 3,587 ms |
コンパイル使用メモリ | 78,876 KB |
実行使用メモリ | 41,352 KB |
最終ジャッジ日時 | 2024-04-23 13:16:57 |
合計ジャッジ時間 | 6,514 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 129 ms
41,040 KB |
testcase_01 | AC | 131 ms
41,104 KB |
testcase_02 | AC | 126 ms
40,956 KB |
testcase_03 | AC | 132 ms
40,956 KB |
testcase_04 | AC | 130 ms
41,140 KB |
testcase_05 | AC | 124 ms
40,880 KB |
testcase_06 | AC | 122 ms
40,912 KB |
testcase_07 | AC | 125 ms
40,972 KB |
testcase_08 | AC | 128 ms
41,232 KB |
testcase_09 | AC | 128 ms
41,060 KB |
testcase_10 | AC | 129 ms
41,164 KB |
testcase_11 | AC | 129 ms
41,064 KB |
testcase_12 | AC | 132 ms
40,876 KB |
testcase_13 | AC | 134 ms
41,168 KB |
testcase_14 | AC | 128 ms
41,352 KB |
testcase_15 | AC | 127 ms
41,172 KB |
testcase_16 | AC | 103 ms
39,652 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; } }