結果

問題 No.185 和風
ユーザー harhogefooharhogefoo
提出日時 2016-10-12 08:32:24
言語 Ruby
(3.3.0)
結果
AC  
実行時間 96 ms / 1,000 ms
コード長 231 bytes
コンパイル時間 39 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-05-01 20:15:19
合計ジャッジ時間 1,204 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
12,160 KB
testcase_01 AC 96 ms
12,288 KB
testcase_02 AC 84 ms
12,160 KB
testcase_03 AC 84 ms
12,288 KB
testcase_04 AC 88 ms
12,160 KB
testcase_05 AC 87 ms
12,288 KB
testcase_06 AC 93 ms
12,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:7: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:12: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

n = gets.to_i
x, y = gets.chomp.split(" ").map(&:to_i)
answer = y - x
(n-1).times do |i|
  x, y = gets.chomp.split(" ").map(&:to_i)
  if answer != y - x
    puts -1
    exit
  end
end
if answer <= 0
  puts -1
else
  puts answer
end
0