結果
問題 | No.205 マージして辞書順最小 |
ユーザー | PG-practice |
提出日時 | 2019-09-28 15:14:53 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,658 bytes |
コンパイル時間 | 2,325 ms |
コンパイル使用メモリ | 80,296 KB |
実行使用メモリ | 57,480 KB |
最終ジャッジ日時 | 2024-04-10 06:35:20 |
合計ジャッジ時間 | 5,999 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 129 ms
53,108 KB |
testcase_01 | AC | 130 ms
54,372 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 121 ms
53,136 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 179 ms
57,060 KB |
testcase_11 | AC | 177 ms
57,468 KB |
testcase_12 | WA | - |
testcase_13 | AC | 167 ms
57,084 KB |
testcase_14 | AC | 136 ms
54,204 KB |
testcase_15 | AC | 118 ms
52,868 KB |
testcase_16 | AC | 134 ms
54,572 KB |
testcase_17 | AC | 138 ms
54,108 KB |
testcase_18 | WA | - |
ソースコード
import java.util.*; //mport java.io.*; // class MyComparator implements Comparator<String>{ // @Override // int compare(String str1,String str2){ // } // } public class Main{ static int INFTY = Integer.MAX_VALUE; public static void main (String args[]){ //初期処理 Scanner sc=new Scanner(System.in); // BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // try{ // int n = Integer.parseInt(br.readLine()); int n= sc.nextInt(); sc.nextLine(); String T = ""; List<String> str = new LinkedList<>(); for(int i=0;i<n;i++){ String tmp = sc.nextLine(); if(!tmp.equals("")){ str.add(tmp); } } while(true){ int candidateIndex=0; if(str.size()==1 && str.get(0).equals("")){ break; } for(int i=0;i<str.size();i++){ if(str.get(i).length()==0){ str.remove(i); i--; continue; } if(str.get(i).compareTo(str.get(candidateIndex))<=0){ candidateIndex=i; } } T += str.get(candidateIndex).substring(0,1); str.set(candidateIndex,str.get(candidateIndex).substring(1,str.get(candidateIndex).length())); } System.out.println(T); } }