結果
問題 | No.1425 Yet Another Cyclic Shifts Sorting |
ユーザー |
![]() |
提出日時 | 2021-03-13 00:03:41 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 603 bytes |
コンパイル時間 | 167 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 131,640 KB |
最終ジャッジ日時 | 2024-10-14 14:27:51 |
合計ジャッジ時間 | 5,383 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 45 WA * 3 |
ソースコード
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])) m = min(A) if down[N]==1: for i in range(N-1): if A[i]>A[i+1] and A[i+1]==m and A[-1]<=A[0]: 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)