結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー simansiman
提出日時 2021-03-18 05:51:24
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 345 bytes
コンパイル時間 45 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 33,408 KB
最終ジャッジ日時 2024-04-27 18:51:51
合計ジャッジ時間 9,374 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
12,160 KB
testcase_01 AC 92 ms
12,288 KB
testcase_02 AC 84 ms
12,288 KB
testcase_03 AC 85 ms
12,288 KB
testcase_04 RE -
testcase_05 AC 92 ms
12,288 KB
testcase_06 AC 87 ms
12,160 KB
testcase_07 AC 85 ms
12,288 KB
testcase_08 AC 85 ms
12,160 KB
testcase_09 AC 88 ms
12,160 KB
testcase_10 RE -
testcase_11 AC 86 ms
12,288 KB
testcase_12 AC 85 ms
12,288 KB
testcase_13 RE -
testcase_14 AC 86 ms
12,032 KB
testcase_15 AC 86 ms
12,032 KB
testcase_16 AC 86 ms
12,288 KB
testcase_17 AC 86 ms
12,032 KB
testcase_18 AC 86 ms
12,032 KB
testcase_19 RE -
testcase_20 AC 85 ms
12,032 KB
testcase_21 AC 86 ms
12,032 KB
testcase_22 AC 201 ms
30,208 KB
testcase_23 AC 117 ms
16,128 KB
testcase_24 AC 112 ms
15,616 KB
testcase_25 AC 214 ms
30,720 KB
testcase_26 AC 237 ms
33,152 KB
testcase_27 AC 225 ms
31,488 KB
testcase_28 AC 251 ms
33,152 KB
testcase_29 AC 143 ms
18,816 KB
testcase_30 AC 128 ms
16,256 KB
testcase_31 AC 250 ms
32,896 KB
testcase_32 AC 130 ms
16,640 KB
testcase_33 AC 95 ms
12,672 KB
testcase_34 AC 144 ms
18,944 KB
testcase_35 AC 243 ms
32,384 KB
testcase_36 AC 223 ms
25,472 KB
testcase_37 AC 111 ms
14,720 KB
testcase_38 AC 278 ms
33,280 KB
testcase_39 AC 98 ms
12,416 KB
testcase_40 AC 247 ms
30,464 KB
testcase_41 AC 153 ms
19,072 KB
testcase_42 AC 165 ms
19,328 KB
testcase_43 AC 96 ms
12,544 KB
testcase_44 AC 112 ms
14,592 KB
testcase_45 AC 282 ms
33,408 KB
testcase_46 AC 284 ms
33,152 KB
testcase_47 AC 281 ms
33,152 KB
testcase_48 AC 282 ms
33,152 KB
testcase_49 AC 282 ms
33,280 KB
testcase_50 AC 88 ms
12,032 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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
0