結果

問題 No.4 おもりと天秤
ユーザー tanukidontanukidon
提出日時 2018-04-09 02:12:18
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 281 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 11,432 KB
実行使用メモリ 15,356 KB
最終ジャッジ日時 2023-09-09 03:20:57
合計ジャッジ時間 3,033 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,032 KB
testcase_01 AC 80 ms
15,108 KB
testcase_02 WA -
testcase_03 AC 81 ms
15,140 KB
testcase_04 AC 82 ms
15,108 KB
testcase_05 AC 81 ms
15,024 KB
testcase_06 WA -
testcase_07 AC 82 ms
15,264 KB
testcase_08 AC 84 ms
15,176 KB
testcase_09 AC 79 ms
15,352 KB
testcase_10 AC 80 ms
15,036 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 80 ms
15,160 KB
testcase_17 AC 79 ms
15,100 KB
testcase_18 WA -
testcase_19 AC 79 ms
15,112 KB
testcase_20 AC 80 ms
15,040 KB
testcase_21 AC 81 ms
15,072 KB
testcase_22 AC 81 ms
15,268 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
a = gets.chomp.split.map(&:to_i).map{|i| i%2}
c = 0
n.times do |i|
  b = a.rotate(i).dup
  x = b.shift
  y = 0
  b.each do |j|
    if x < y
      x += j
    else
      y += j
    end
  end
  c +=1 if x == y
  break if c > 0
end
puts c == 1 ? "possible" : "impossible"
0