結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー yuusanlondon
提出日時 2021-03-12 22:43:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 336 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 81,908 KB
実行使用メモリ 117,468 KB
最終ジャッジ日時 2024-10-14 13:17:33
合計ジャッジ時間 9,606 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(map(int,input().split()))
c=[]
for i in range(n):
  c.append((a[i],i))
c.sort()
b=[0]*n
for i in range(n):
  b[c[i][1]]=i
ans=0
pointer=0
if b[n-1]!=n-1:
  ans+=1
for i in range(n-2,-1,-1):
  if pointer>=i:
      break
  if b[i]+1!=b[i+1]:
    if b[i+1]==pointer:
      pointer+=1
    else:
      ans+=1
print(ans)
0