結果

問題 No.185 和風
ユーザー what_alnk
提出日時 2015-09-02 20:49:57
言語 Ruby
(3.4.1)
結果
AC  
実行時間 88 ms / 1,000 ms
コード長 266 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 12,160 KB
最終ジャッジ日時 2024-07-18 21:36:50
合計ジャッジ時間 1,737 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
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