結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー 👑 tamatotamato
提出日時 2021-03-12 22:15:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 818 bytes
コンパイル時間 689 ms
コンパイル使用メモリ 87,596 KB
実行使用メモリ 104,496 KB
最終ジャッジ日時 2023-08-04 19:05:02
合計ジャッジ時間 6,926 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,736 KB
testcase_01 AC 66 ms
71,716 KB
testcase_02 AC 67 ms
71,640 KB
testcase_03 AC 66 ms
71,600 KB
testcase_04 AC 66 ms
71,632 KB
testcase_05 AC 68 ms
71,724 KB
testcase_06 AC 64 ms
71,588 KB
testcase_07 AC 66 ms
71,632 KB
testcase_08 AC 67 ms
71,736 KB
testcase_09 AC 66 ms
71,632 KB
testcase_10 AC 67 ms
71,636 KB
testcase_11 AC 67 ms
71,552 KB
testcase_12 AC 66 ms
71,752 KB
testcase_13 AC 65 ms
71,448 KB
testcase_14 AC 69 ms
71,896 KB
testcase_15 AC 66 ms
71,420 KB
testcase_16 AC 68 ms
71,504 KB
testcase_17 AC 68 ms
71,712 KB
testcase_18 AC 67 ms
71,580 KB
testcase_19 AC 66 ms
71,756 KB
testcase_20 AC 66 ms
71,596 KB
testcase_21 AC 67 ms
71,728 KB
testcase_22 AC 104 ms
101,248 KB
testcase_23 AC 78 ms
80,268 KB
testcase_24 AC 75 ms
79,528 KB
testcase_25 AC 105 ms
104,496 KB
testcase_26 AC 116 ms
101,124 KB
testcase_27 AC 107 ms
98,584 KB
testcase_28 AC 118 ms
101,344 KB
testcase_29 AC 84 ms
84,712 KB
testcase_30 AC 82 ms
81,376 KB
testcase_31 AC 123 ms
101,488 KB
testcase_32 AC 80 ms
83,320 KB
testcase_33 AC 70 ms
76,256 KB
testcase_34 AC 83 ms
85,848 KB
testcase_35 AC 114 ms
99,408 KB
testcase_36 AC 114 ms
98,628 KB
testcase_37 AC 79 ms
78,456 KB
testcase_38 AC 148 ms
103,156 KB
testcase_39 AC 70 ms
76,012 KB
testcase_40 AC 126 ms
102,604 KB
testcase_41 AC 87 ms
84,388 KB
testcase_42 AC 93 ms
87,484 KB
testcase_43 AC 71 ms
76,064 KB
testcase_44 AC 73 ms
77,672 KB
testcase_45 AC 143 ms
103,180 KB
testcase_46 AC 152 ms
102,592 KB
testcase_47 AC 151 ms
103,252 KB
testcase_48 AC 148 ms
102,716 KB
testcase_49 AC 147 ms
103,052 KB
testcase_50 AC 69 ms
71,676 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