結果
| 問題 | No.365 ジェンガソート | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2016-05-22 18:46:23 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 357 bytes | 
| コンパイル時間 | 134 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 23,524 KB | 
| 最終ジャッジ日時 | 2024-10-06 20:36:15 | 
| 合計ジャッジ時間 | 4,554 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 16 TLE * 1 -- * 24 | 
ソースコード
def jenga_sort(A):
    d = {}
    for i in reversed(range(1, N)):
        for j in range(i):
            if A[i] < A[j]:
                d[A[i]] = i
                break
    if len(d) == 0:
        return 0
        
    A.insert(0, A.pop(d[max(d)]))
    return jenga_sort(A) + 1
N = int(input())
A = [int(i) for i in input().split()]
print(jenga_sort(A))
            
            
            
        