結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー H3PO4H3PO4
提出日時 2022-07-26 08:18:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 557 bytes
コンパイル時間 1,433 ms
コンパイル使用メモリ 86,632 KB
実行使用メモリ 105,928 KB
最終ジャッジ日時 2023-09-22 23:55:50
合計ジャッジ時間 9,784 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,356 KB
testcase_01 AC 69 ms
71,188 KB
testcase_02 AC 70 ms
71,192 KB
testcase_03 AC 69 ms
71,296 KB
testcase_04 AC 69 ms
71,080 KB
testcase_05 WA -
testcase_06 AC 71 ms
71,232 KB
testcase_07 AC 71 ms
71,324 KB
testcase_08 WA -
testcase_09 AC 69 ms
71,236 KB
testcase_10 AC 69 ms
71,188 KB
testcase_11 AC 69 ms
71,284 KB
testcase_12 AC 69 ms
71,244 KB
testcase_13 AC 69 ms
71,356 KB
testcase_14 AC 68 ms
71,184 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 68 ms
71,232 KB
testcase_19 AC 68 ms
71,332 KB
testcase_20 AC 70 ms
71,252 KB
testcase_21 AC 69 ms
70,908 KB
testcase_22 AC 106 ms
102,460 KB
testcase_23 AC 80 ms
80,320 KB
testcase_24 AC 79 ms
79,436 KB
testcase_25 AC 111 ms
105,928 KB
testcase_26 AC 122 ms
100,888 KB
testcase_27 AC 118 ms
99,376 KB
testcase_28 AC 122 ms
102,068 KB
testcase_29 AC 85 ms
85,044 KB
testcase_30 AC 81 ms
81,684 KB
testcase_31 AC 121 ms
102,408 KB
testcase_32 AC 82 ms
83,916 KB
testcase_33 AC 74 ms
75,952 KB
testcase_34 AC 87 ms
86,088 KB
testcase_35 AC 119 ms
100,348 KB
testcase_36 AC 124 ms
100,868 KB
testcase_37 AC 82 ms
78,440 KB
testcase_38 AC 159 ms
104,552 KB
testcase_39 AC 76 ms
75,812 KB
testcase_40 AC 136 ms
105,508 KB
testcase_41 AC 97 ms
85,372 KB
testcase_42 AC 104 ms
88,724 KB
testcase_43 AC 76 ms
75,848 KB
testcase_44 AC 81 ms
78,016 KB
testcase_45 AC 159 ms
104,932 KB
testcase_46 AC 161 ms
103,868 KB
testcase_47 AC 159 ms
104,604 KB
testcase_48 AC 158 ms
104,124 KB
testcase_49 AC 159 ms
104,476 KB
testcase_50 AC 69 ms
71,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def find_sorted_min_idx(N, A):
    SA = sorted(A)
    for i in range(N - 1, -1, -1):
        if A[i] != SA[i]:
            return i + 1
    return 0


def is_cyclic_shift(N, A):
    ct = 0
    for i in range(N - 1):
        if A[i] > A[i + 1]:
            ct += 1
    return ct <= 1


def solve(N, A):
    sorted_min_idx = find_sorted_min_idx(N, A)
    if not sorted_min_idx:
        return 0
    if is_cyclic_shift(sorted_min_idx, A[:sorted_min_idx]):
        return 1
    return 2


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