結果

問題 No.185 和風
ユーザー what_alnkwhat_alnk
提出日時 2015-09-02 20:49:57
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 1,000 ms
コード長 266 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 11,532 KB
実行使用メモリ 15,328 KB
最終ジャッジ日時 2023-09-26 02:14:57
合計ジャッジ時間 1,814 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,328 KB
testcase_01 AC 82 ms
15,284 KB
testcase_02 AC 78 ms
15,284 KB
testcase_03 AC 80 ms
15,092 KB
testcase_04 AC 77 ms
15,120 KB
testcase_05 AC 77 ms
15,144 KB
testcase_06 AC 84 ms
15,140 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:9: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:17: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

n = gets.chomp.to_i
res = []
flag = true
n.times do
  x, y = gets.chomp.split(" ").map(&:to_i)
  if y - x > 0 then
    res << y - x
  else
    puts -1
    flag = false
    break
  end
end
if flag and res.uniq.length == 1 then
  puts res[0]
else
  puts -1 if flag
end
0