結果

問題 No.1053 ゲーミング棒
ユーザー simansiman
提出日時 2021-01-25 22:59:01
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 325 bytes
コンパイル時間 429 ms
コンパイル使用メモリ 11,304 KB
実行使用メモリ 25,796 KB
最終ジャッジ日時 2023-09-05 02:09:34
合計ジャッジ時間 8,851 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
22,212 KB
testcase_01 AC 87 ms
15,068 KB
testcase_02 AC 88 ms
15,312 KB
testcase_03 AC 91 ms
15,068 KB
testcase_04 AC 88 ms
15,292 KB
testcase_05 AC 87 ms
15,048 KB
testcase_06 AC 86 ms
15,132 KB
testcase_07 AC 86 ms
15,048 KB
testcase_08 AC 88 ms
15,300 KB
testcase_09 AC 86 ms
15,332 KB
testcase_10 AC 85 ms
15,056 KB
testcase_11 AC 85 ms
15,164 KB
testcase_12 AC 85 ms
15,332 KB
testcase_13 AC 87 ms
15,264 KB
testcase_14 AC 85 ms
15,256 KB
testcase_15 AC 84 ms
15,244 KB
testcase_16 AC 86 ms
15,300 KB
testcase_17 AC 85 ms
15,100 KB
testcase_18 AC 84 ms
15,056 KB
testcase_19 AC 87 ms
15,168 KB
testcase_20 AC 85 ms
15,140 KB
testcase_21 AC 83 ms
15,148 KB
testcase_22 AC 84 ms
15,244 KB
testcase_23 AC 147 ms
25,684 KB
testcase_24 AC 144 ms
25,796 KB
testcase_25 AC 145 ms
25,664 KB
testcase_26 AC 148 ms
25,508 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
  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