結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー tamatotamato
提出日時 2021-03-12 22:15:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 818 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 82,164 KB
実行使用メモリ 104,616 KB
最終ジャッジ日時 2024-04-22 17:09:41
合計ジャッジ時間 4,955 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,356 KB
testcase_01 AC 37 ms
52,904 KB
testcase_02 AC 36 ms
53,056 KB
testcase_03 AC 36 ms
53,468 KB
testcase_04 AC 36 ms
52,712 KB
testcase_05 AC 36 ms
52,852 KB
testcase_06 AC 35 ms
54,068 KB
testcase_07 AC 35 ms
52,956 KB
testcase_08 AC 37 ms
52,812 KB
testcase_09 AC 36 ms
52,808 KB
testcase_10 AC 37 ms
52,948 KB
testcase_11 AC 36 ms
52,788 KB
testcase_12 AC 36 ms
52,848 KB
testcase_13 AC 36 ms
54,504 KB
testcase_14 AC 37 ms
52,464 KB
testcase_15 AC 35 ms
53,692 KB
testcase_16 AC 36 ms
53,428 KB
testcase_17 AC 35 ms
52,608 KB
testcase_18 AC 36 ms
53,264 KB
testcase_19 AC 36 ms
52,872 KB
testcase_20 AC 36 ms
54,132 KB
testcase_21 AC 36 ms
52,592 KB
testcase_22 AC 79 ms
100,220 KB
testcase_23 AC 47 ms
69,028 KB
testcase_24 AC 45 ms
67,144 KB
testcase_25 AC 81 ms
103,456 KB
testcase_26 AC 94 ms
100,088 KB
testcase_27 AC 79 ms
101,720 KB
testcase_28 AC 94 ms
100,196 KB
testcase_29 AC 54 ms
75,076 KB
testcase_30 AC 49 ms
70,916 KB
testcase_31 AC 93 ms
100,180 KB
testcase_32 AC 51 ms
72,392 KB
testcase_33 AC 41 ms
60,320 KB
testcase_34 AC 54 ms
75,652 KB
testcase_35 AC 84 ms
104,616 KB
testcase_36 AC 89 ms
93,348 KB
testcase_37 AC 48 ms
66,600 KB
testcase_38 AC 124 ms
101,816 KB
testcase_39 AC 41 ms
59,836 KB
testcase_40 AC 102 ms
99,116 KB
testcase_41 AC 61 ms
74,108 KB
testcase_42 AC 66 ms
78,664 KB
testcase_43 AC 41 ms
60,988 KB
testcase_44 AC 45 ms
64,980 KB
testcase_45 AC 126 ms
102,204 KB
testcase_46 AC 124 ms
101,428 KB
testcase_47 AC 125 ms
102,068 KB
testcase_48 AC 124 ms
101,444 KB
testcase_49 AC 125 ms
101,824 KB
testcase_50 AC 36 ms
52,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    A_sorted = sorted(A)
    if A == A_sorted:
        print(0)
    else:
        ii = -1
        for i in range(1, N):
            if A[i] < A[i-1]:
                if ii != -1:
                    print(2)
                    exit()
                else:
                    ii = i
        if ii == -1:
            print(2)
            exit()
        if A[ii] > A[0]:
            print(2)
            exit()
        for i in range(ii, N-1):
            if A[i] <= A[0] and A[i+1] >= A[ii-1]:
                print(1)
                exit()
        if A[-1] <= A[0]:
            print(1)
            exit()
        print(2)


if __name__ == '__main__':
    main()
0