結果
問題 | No.205 マージして辞書順最小 |
ユーザー | PG-practice |
提出日時 | 2019-09-28 16:34:07 |
言語 | Java19 (openjdk 21) |
結果 |
AC
|
実行時間 | 856 ms / 5,000 ms |
コード長 | 1,773 bytes |
コンパイル時間 | 3,657 ms |
コンパイル使用メモリ | 82,780 KB |
実行使用メモリ | 70,172 KB |
最終ジャッジ日時 | 2023-07-25 17:10:49 |
合計ジャッジ時間 | 13,682 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 152 ms
56,680 KB |
testcase_01 | AC | 156 ms
58,932 KB |
testcase_02 | AC | 418 ms
60,720 KB |
testcase_03 | AC | 493 ms
60,224 KB |
testcase_04 | AC | 461 ms
60,076 KB |
testcase_05 | AC | 442 ms
58,400 KB |
testcase_06 | AC | 195 ms
57,076 KB |
testcase_07 | AC | 837 ms
65,600 KB |
testcase_08 | AC | 809 ms
63,668 KB |
testcase_09 | AC | 838 ms
64,532 KB |
testcase_10 | AC | 828 ms
70,172 KB |
testcase_11 | AC | 856 ms
67,360 KB |
testcase_12 | AC | 778 ms
64,768 KB |
testcase_13 | AC | 631 ms
61,748 KB |
testcase_14 | AC | 232 ms
60,040 KB |
testcase_15 | AC | 155 ms
54,812 KB |
testcase_16 | AC | 155 ms
56,756 KB |
testcase_17 | AC | 158 ms
56,964 KB |
testcase_18 | AC | 151 ms
56,584 KB |
ソースコード
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(candidateIndex).matches("^"+str.get(i)+".*") && str.get(i).compareTo(str.get(candidateIndex))<=0) || str.get(i).matches("^"+str.get(candidateIndex)+".*")){ 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); } }