結果
| 問題 |
No.1604 Swap Sort:ONE
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-16 22:53:08 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 381 bytes |
| コンパイル時間 | 347 ms |
| コンパイル使用メモリ | 82,188 KB |
| 実行使用メモリ | 82,616 KB |
| 最終ジャッジ日時 | 2024-07-06 10:25:12 |
| 合計ジャッジ時間 | 4,047 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 TLE * 1 -- * 20 |
ソースコード
N = int(input())
P = list(map(int,input().split()))
cnt = 0
Q = [0 for _ in range(N+1)]
for index,p in enumerate(P):
Q[p] = index
flag = True
j = 1
while flag:
flag = False
if Q[j] == j -1:
j += 1
for i in range(j,N):
if Q[i] > Q[i+1]:
Q[i],Q[i+1] = Q[i+1],Q[i]
flag = True
cnt += 1
break
print(cnt)