結果
問題 |
No.1425 Yet Another Cyclic Shifts Sorting
|
ユーザー |
![]() |
提出日時 | 2021-03-18 05:51:24 |
言語 | Ruby (3.4.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 345 bytes |
コンパイル時間 | 66 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 33,280 KB |
最終ジャッジ日時 | 2024-11-15 23:37:12 |
合計ジャッジ時間 | 9,208 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 44 RE * 4 |
コンパイルメッセージ
Syntax OK
ソースコード
N = gets.to_i A = gets.split.map(&:to_i) B = A.sort if A.each_cons(2).count { |a, b| a > b } == 0 puts 0 exit end i = N - 1 while A[i] == B[i] && i >= 0 i -= 1 end C = A[0..i] D = C.size cnt = 0 D.times do |j| a = C[j] b = C[(j + 1) % D] cnt += 1 if a > b end if cnt == 1 && C.max <= A[i + 1..-1].max puts 1 else puts 2 end