結果
| 問題 |
No.1425 Yet Another Cyclic Shifts Sorting
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2021-03-18 05:52:53 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 290 ms / 2,000 ms |
| コード長 | 375 bytes |
| コンパイル時間 | 80 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 33,280 KB |
| 最終ジャッジ日時 | 2024-11-15 23:38:11 |
| 合計ジャッジ時間 | 9,199 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 48 |
コンパイルメッセージ
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
m = (i == N - 1) ? A.max : A[i + 1..-1].max
if cnt == 1 && C.max <= m
puts 1
else
puts 2
end
siman