結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー convexineq
提出日時 2021-03-13 00:06:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 528 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 108,620 KB
最終ジャッジ日時 2024-10-14 14:29:14
合計ジャッジ時間 5,005 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 28 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
*a, = map(int,input().split())
v = 10**10
p = [0]*n
for i in range(n)[::-1]:
    if a[i] > v: break
    p[i] = 1
    v = a[i]
v = -1
q = [0]*n
for i in range(n):
    if a[i] < v: break
    q[i] = 1
    v = a[i]
idx = i
v = q[idx]
for i in range(idx,n):
    if a[i] < v: break
    q[i] = 1
    v = a[i]

L,R = q[0],q[idx-1]
ans = 2
for i in range(idx,n):
    if q[i-1] == p[i] == 1 and a[i-1] <= L and R <= a[i]:
        ans = 1
        print(i)

#print(p)
#print(idx,q)
if p[0] == 1:
    ans = 0
print(ans)




0