結果

問題 No.365 ジェンガソート
コンテスト
ユーザー 回転
提出日時 2026-05-22 18:21:23
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 334 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 162 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 99,072 KB
最終ジャッジ日時 2026-05-22 18:21:30
合計ジャッジ時間 3,940 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import heapq
N = int(input())
A = list(map(int,input().split()))
A = A[::-1]

ans = 0
count = 1
free = []
while(A):
    while(free and free[0] == count):
        heapq.heappop(free)
        count += 1
    if(A[-1] == count):
        A.pop()
        count += 1
    else:
        ans += 1
        heapq.heappush(free,A.pop())
print(ans)
0