結果
問題 | No.342 一番ワロタww |
ユーザー | 37zigen |
提出日時 | 2016-03-22 15:25:23 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 167 ms / 5,000 ms |
コード長 | 1,234 bytes |
コンパイル時間 | 2,349 ms |
コンパイル使用メモリ | 80,776 KB |
実行使用メモリ | 55,284 KB |
最終ジャッジ日時 | 2024-04-23 13:23:48 |
合計ジャッジ時間 | 5,825 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 165 ms
55,180 KB |
testcase_01 | AC | 164 ms
55,096 KB |
testcase_02 | AC | 167 ms
55,284 KB |
testcase_03 | AC | 158 ms
55,016 KB |
testcase_04 | AC | 159 ms
54,988 KB |
testcase_05 | AC | 159 ms
54,896 KB |
testcase_06 | AC | 161 ms
54,960 KB |
testcase_07 | AC | 162 ms
55,052 KB |
testcase_08 | AC | 165 ms
54,780 KB |
testcase_09 | AC | 161 ms
54,800 KB |
testcase_10 | AC | 159 ms
55,004 KB |
testcase_11 | AC | 162 ms
54,904 KB |
testcase_12 | AC | 157 ms
54,932 KB |
testcase_13 | AC | 163 ms
55,212 KB |
testcase_14 | AC | 166 ms
55,136 KB |
testcase_15 | AC | 127 ms
54,124 KB |
testcase_16 | AC | 161 ms
55,192 KB |
ソースコード
package yukicoder342; import java.util.PriorityQueue; import java.util.Scanner; public class Main { static class Tuple implements Comparable<Tuple>{ String str; int count; Tuple(String str,int count){ this.str=str; this.count=count; } public int compareTo(Tuple o){ int a=Integer.compare(o.count, count); if(a==0)return 1; return a; } } public static void main(String[] args){ Scanner sc=new Scanner(System.in); String str=sc.nextLine(); PriorityQueue<Tuple> queue=new PriorityQueue(100); String str2=""; int count=0; for(int i=0;i<str.length();i++){ if(str.charAt(i)=='w'&&i==str.length()-1){ count++; queue.add(new Tuple(str2,count)); }else if(str.charAt(i)!='w'){ if(i>=1){ if(str.charAt(i-1)=='w'){ if(!str2.equals("")){ queue.add(new Tuple(str2,count)); } str2=""; count=0; } } str2+=str.charAt(i); }else if(str.charAt(i)=='w'){ count++; } } if(queue.isEmpty()){ System.out.println(); System.exit(0); } int a=queue.peek().count; while(!queue.isEmpty()){ Tuple t=queue.poll(); if(a!=t.count)break; System.out.println(t.str); } // System.err.println("End"); sc.close(); } }