結果
問題 | No.342 一番ワロタww |
ユーザー |
![]() |
提出日時 | 2016-02-12 23:59:47 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 134 ms / 5,000 ms |
コード長 | 1,262 bytes |
コンパイル時間 | 3,637 ms |
コンパイル使用メモリ | 78,704 KB |
実行使用メモリ | 44,704 KB |
最終ジャッジ日時 | 2024-10-15 13:15:17 |
合計ジャッジ時間 | 6,548 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
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;}}