結果
問題 | No.205 マージして辞書順最小 |
ユーザー | ayaoni |
提出日時 | 2021-08-30 22:20:24 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 105 ms / 5,000 ms |
コード長 | 1,025 bytes |
コンパイル時間 | 351 ms |
コンパイル使用メモリ | 87,052 KB |
実行使用メモリ | 77,532 KB |
最終ジャッジ日時 | 2023-08-15 21:50:50 |
合計ジャッジ時間 | 2,863 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 64 ms
71,460 KB |
testcase_01 | AC | 62 ms
71,292 KB |
testcase_02 | AC | 99 ms
77,276 KB |
testcase_03 | AC | 89 ms
77,524 KB |
testcase_04 | AC | 87 ms
77,404 KB |
testcase_05 | AC | 90 ms
77,316 KB |
testcase_06 | AC | 62 ms
71,512 KB |
testcase_07 | AC | 93 ms
77,396 KB |
testcase_08 | AC | 86 ms
76,968 KB |
testcase_09 | AC | 86 ms
77,204 KB |
testcase_10 | AC | 90 ms
77,244 KB |
testcase_11 | AC | 99 ms
77,532 KB |
testcase_12 | AC | 105 ms
77,356 KB |
testcase_13 | AC | 96 ms
77,444 KB |
testcase_14 | AC | 74 ms
75,932 KB |
testcase_15 | AC | 65 ms
71,244 KB |
testcase_16 | AC | 62 ms
71,540 KB |
testcase_17 | AC | 64 ms
71,348 KB |
testcase_18 | AC | 64 ms
71,048 KB |
ソースコード
import sys def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) N = I() S = [S()+'{' for _ in range(N)] S.sort() ANS = [] while True: L = [[] for _ in range(26)] for s in S: L[ord(s[0])-97].append(s) for i in range(26): if L[i]: L[i].sort() ANS.append(L[i][0][0]) new = [] if len(L[i][0]) >= 3: new.append(L[i][0][1:]) for s in L[i][1:]: new.append(s) for j in range(i+1,26): for s in L[j]: new.append(s) S = new break else: break ans = ''.join(ANS) print(ans)