結果
問題 | No.342 一番ワロタww |
ユーザー | YamaKasa |
提出日時 | 2018-09-16 22:14:25 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,444 bytes |
コンパイル時間 | 2,471 ms |
コンパイル使用メモリ | 76,788 KB |
実行使用メモリ | 58,180 KB |
最終ジャッジ日時 | 2023-09-25 09:11:33 |
合計ジャッジ時間 | 6,106 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 120 ms
55,872 KB |
testcase_01 | AC | 121 ms
55,864 KB |
testcase_02 | AC | 123 ms
55,996 KB |
testcase_03 | AC | 121 ms
55,588 KB |
testcase_04 | AC | 121 ms
56,156 KB |
testcase_05 | AC | 122 ms
55,832 KB |
testcase_06 | AC | 122 ms
56,088 KB |
testcase_07 | WA | - |
testcase_08 | AC | 120 ms
56,044 KB |
testcase_09 | AC | 122 ms
56,096 KB |
testcase_10 | AC | 123 ms
54,248 KB |
testcase_11 | AC | 122 ms
55,628 KB |
testcase_12 | AC | 123 ms
55,432 KB |
testcase_13 | AC | 122 ms
55,956 KB |
testcase_14 | AC | 121 ms
55,776 KB |
testcase_15 | AC | 125 ms
55,944 KB |
testcase_16 | AC | 123 ms
55,828 KB |
ソースコード
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String S = scan.next(); scan.close(); if(S.substring(0, 1).equals("w")) { for(int i = 0; i < S.length(); i++) { if(S.substring(i, i + 1).equals("w")) { continue; }else { S = S.substring(i, S.length()); break; } } } S = S + " "; String []ary = new String[S.length()]; for(int i = 0; i < S.length(); i++) { ary[i] = S.substring(i, i + 1); } int l = ary.length; int max = 0; List<Data>list = new ArrayList<Data>(); int begin = 0; for(int i = 0; i < l; i++) { if(ary[i].equals("w")) { int cnt = 1; int t = i; i++; while(i < l) { if(ary[i].equals("w")) { cnt ++; i++; continue; }else { String s = S.substring(begin, t); begin = i; Data d = new Data(s, cnt); list.add(d); if(max < cnt) { max = cnt; } break; } } } } StringBuilder sb = new StringBuilder(); for(int i = 0; i < list.size(); i++) { if(list.get(i).getN() == max) { sb.append(list.get(i).getS()).append("\n"); } } System.out.print(sb.toString()); } } class Data{ String s; int n; public Data(String s, int n) { this.s = s; this.n = n; } String getS() { return s; } int getN() { return n; } }