結果

問題 No.1053 ゲーミング棒
ユーザー simansiman
提出日時 2021-01-25 22:59:48
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 331 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 11,476 KB
実行使用メモリ 26,464 KB
最終ジャッジ日時 2023-09-05 02:10:52
合計ジャッジ時間 11,976 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,264 KB
testcase_01 AC 82 ms
15,168 KB
testcase_02 AC 85 ms
15,268 KB
testcase_03 AC 83 ms
15,260 KB
testcase_04 AC 81 ms
15,104 KB
testcase_05 AC 83 ms
15,144 KB
testcase_06 AC 81 ms
15,172 KB
testcase_07 AC 82 ms
15,360 KB
testcase_08 AC 82 ms
15,300 KB
testcase_09 AC 80 ms
15,092 KB
testcase_10 AC 81 ms
15,100 KB
testcase_11 AC 81 ms
15,068 KB
testcase_12 AC 83 ms
15,288 KB
testcase_13 AC 81 ms
15,108 KB
testcase_14 AC 83 ms
15,216 KB
testcase_15 AC 81 ms
15,324 KB
testcase_16 AC 83 ms
15,288 KB
testcase_17 AC 84 ms
15,140 KB
testcase_18 AC 83 ms
15,060 KB
testcase_19 AC 81 ms
15,068 KB
testcase_20 AC 82 ms
15,352 KB
testcase_21 AC 81 ms
15,180 KB
testcase_22 AC 81 ms
15,304 KB
testcase_23 AC 157 ms
26,440 KB
testcase_24 AC 159 ms
26,348 KB
testcase_25 AC 160 ms
26,412 KB
testcase_26 AC 161 ms
26,464 KB
testcase_27 AC 86 ms
15,316 KB
testcase_28 AC 86 ms
15,148 KB
testcase_29 AC 86 ms
15,272 KB
testcase_30 AC 129 ms
22,532 KB
testcase_31 AC 1,164 ms
22,296 KB
testcase_32 TLE -
testcase_33 AC 909 ms
22,324 KB
testcase_34 AC 1,221 ms
22,320 KB
testcase_35 AC 649 ms
22,408 KB
testcase_36 AC 643 ms
22,556 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 || A.uniq.size == 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