結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー convexineqconvexineq
提出日時 2021-03-13 00:16:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 110,072 KB
最終ジャッジ日時 2024-04-22 17:18:26
合計ジャッジ時間 6,174 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
51,968 KB
testcase_01 AC 47 ms
51,840 KB
testcase_02 AC 48 ms
51,584 KB
testcase_03 AC 45 ms
51,712 KB
testcase_04 AC 47 ms
51,840 KB
testcase_05 AC 44 ms
51,840 KB
testcase_06 AC 46 ms
51,840 KB
testcase_07 AC 46 ms
52,224 KB
testcase_08 AC 48 ms
51,840 KB
testcase_09 AC 45 ms
51,584 KB
testcase_10 AC 44 ms
51,968 KB
testcase_11 AC 45 ms
52,096 KB
testcase_12 AC 45 ms
52,096 KB
testcase_13 AC 47 ms
51,584 KB
testcase_14 AC 46 ms
51,968 KB
testcase_15 AC 44 ms
52,096 KB
testcase_16 AC 43 ms
51,712 KB
testcase_17 AC 44 ms
51,712 KB
testcase_18 AC 47 ms
52,352 KB
testcase_19 AC 46 ms
51,584 KB
testcase_20 AC 45 ms
51,968 KB
testcase_21 AC 45 ms
51,968 KB
testcase_22 AC 117 ms
104,832 KB
testcase_23 AC 66 ms
71,168 KB
testcase_24 AC 67 ms
69,632 KB
testcase_25 AC 125 ms
107,648 KB
testcase_26 AC 131 ms
109,736 KB
testcase_27 AC 129 ms
105,984 KB
testcase_28 AC 138 ms
109,836 KB
testcase_29 AC 85 ms
80,128 KB
testcase_30 AC 76 ms
74,240 KB
testcase_31 AC 135 ms
109,912 KB
testcase_32 AC 79 ms
77,696 KB
testcase_33 AC 59 ms
62,208 KB
testcase_34 AC 86 ms
82,176 KB
testcase_35 AC 131 ms
106,112 KB
testcase_36 AC 100 ms
101,632 KB
testcase_37 AC 64 ms
66,560 KB
testcase_38 AC 131 ms
109,836 KB
testcase_39 AC 53 ms
60,160 KB
testcase_40 AC 119 ms
108,800 KB
testcase_41 AC 71 ms
77,696 KB
testcase_42 AC 73 ms
82,560 KB
testcase_43 AC 54 ms
62,080 KB
testcase_44 AC 58 ms
66,432 KB
testcase_45 AC 128 ms
109,948 KB
testcase_46 AC 131 ms
109,736 KB
testcase_47 AC 131 ms
109,560 KB
testcase_48 AC 129 ms
110,072 KB
testcase_49 AC 129 ms
109,820 KB
testcase_50 AC 44 ms
51,968 KB
権限があれば一括ダウンロードができます

ソースコード

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 = a[0],a[idx-1]
#print(L,R,idx)
a.append(10**10)
p.append(1)
ans = 2
for i in range(idx+1,n+1):
    if q[i-1] == p[i] == 1 and a[i-1] <= L and R <= a[i]:
        ans = 1
#print(p)
#print(idx,q)
if p[0] == 1:
    ans = 0
print(ans)
0