結果

問題 No.1053 ゲーミング棒
ユーザー simansiman
提出日時 2021-01-25 23:01:06
言語 Ruby
(3.3.0)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 345 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 11,308 KB
実行使用メモリ 26,608 KB
最終ジャッジ日時 2023-09-05 02:11:42
合計ジャッジ時間 5,756 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,288 KB
testcase_01 AC 81 ms
15,272 KB
testcase_02 AC 80 ms
15,100 KB
testcase_03 AC 81 ms
15,168 KB
testcase_04 AC 79 ms
15,244 KB
testcase_05 AC 81 ms
15,160 KB
testcase_06 AC 82 ms
15,060 KB
testcase_07 AC 81 ms
15,048 KB
testcase_08 AC 81 ms
15,332 KB
testcase_09 AC 82 ms
15,052 KB
testcase_10 AC 83 ms
15,172 KB
testcase_11 AC 83 ms
15,380 KB
testcase_12 AC 82 ms
15,296 KB
testcase_13 AC 82 ms
15,100 KB
testcase_14 AC 82 ms
15,336 KB
testcase_15 AC 82 ms
15,108 KB
testcase_16 AC 83 ms
15,120 KB
testcase_17 AC 81 ms
15,296 KB
testcase_18 AC 81 ms
15,352 KB
testcase_19 AC 82 ms
15,120 KB
testcase_20 AC 83 ms
15,048 KB
testcase_21 AC 83 ms
15,172 KB
testcase_22 AC 81 ms
15,248 KB
testcase_23 AC 147 ms
26,384 KB
testcase_24 AC 151 ms
26,608 KB
testcase_25 AC 152 ms
26,336 KB
testcase_26 AC 152 ms
26,452 KB
testcase_27 AC 82 ms
15,296 KB
testcase_28 AC 81 ms
15,292 KB
testcase_29 AC 80 ms
15,168 KB
testcase_30 AC 125 ms
22,328 KB
testcase_31 AC 145 ms
22,732 KB
testcase_32 AC 150 ms
22,692 KB
testcase_33 AC 146 ms
22,652 KB
testcase_34 AC 144 ms
22,540 KB
testcase_35 AC 141 ms
22,936 KB
testcase_36 AC 144 ms
22,828 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:30: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)

if N == 1 || A.uniq.size == 1
  puts 0
  exit
end

rotate_cnt = 0

while A[0] == A[-1]
  rotate_cnt += 1
  a = A.shift
  A.push(a)
end

cnt = 0

(N - 1).times do |i|
  cnt += 1 if A[i] != A[i + 1]
end

if cnt == A.uniq.size - 1
  if rotate_cnt == 0
    puts 0
  else
    puts 1
  end
else
  puts -1
end
0