結果

問題 No.1053 ゲーミング棒
ユーザー simansiman
提出日時 2021-01-25 22:56:15
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 311 bytes
コンパイル時間 620 ms
コンパイル使用メモリ 11,476 KB
実行使用メモリ 25,828 KB
最終ジャッジ日時 2023-09-04 21:58:25
合計ジャッジ時間 8,824 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
19,500 KB
testcase_01 AC 85 ms
15,080 KB
testcase_02 AC 82 ms
15,120 KB
testcase_03 AC 83 ms
15,124 KB
testcase_04 AC 83 ms
15,236 KB
testcase_05 AC 83 ms
15,124 KB
testcase_06 AC 82 ms
15,120 KB
testcase_07 AC 83 ms
15,216 KB
testcase_08 AC 84 ms
15,172 KB
testcase_09 AC 82 ms
15,028 KB
testcase_10 AC 83 ms
15,280 KB
testcase_11 AC 83 ms
15,124 KB
testcase_12 AC 82 ms
15,276 KB
testcase_13 AC 81 ms
15,100 KB
testcase_14 AC 81 ms
15,228 KB
testcase_15 AC 81 ms
15,220 KB
testcase_16 AC 82 ms
15,080 KB
testcase_17 AC 82 ms
15,172 KB
testcase_18 AC 80 ms
15,164 KB
testcase_19 AC 81 ms
15,168 KB
testcase_20 AC 81 ms
15,112 KB
testcase_21 AC 82 ms
15,156 KB
testcase_22 AC 81 ms
15,256 KB
testcase_23 AC 144 ms
25,828 KB
testcase_24 AC 142 ms
25,584 KB
testcase_25 AC 143 ms
25,552 KB
testcase_26 AC 142 ms
25,652 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:29: 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.rotate!
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