結果
| 問題 | 
                            No.1425 Yet Another Cyclic Shifts Sorting
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-03-12 23:54:09 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 491 bytes | 
| コンパイル時間 | 628 ms | 
| コンパイル使用メモリ | 82,184 KB | 
| 実行使用メモリ | 131,332 KB | 
| 最終ジャッジ日時 | 2024-10-14 14:18:17 | 
| 合計ジャッジ時間 | 5,535 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 43 WA * 5 | 
ソースコード
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
if A==list(sorted(A)):
    print(0)
    exit()
down = [0, 0]
for i in range(N-1):
    down.append(down[-1]+(1 if A[i]>A[i+1] else 0))
M = [0]
for i in range(N):
    M.append(max(M[-1], A[i]))
if down[N]==1:
    print(1)
    exit()
for i in range(N-2, 0, -1):
    if A[i]<A[i+1]:
        if down[i-1]==1 and M[i]<=A[i]:
            print(1)
            exit()
    else:
        break
print(2)