結果

問題 No.185 和風
ユーザー harhogefoo
提出日時 2016-10-12 08:32:24
言語 Ruby
(4.0.9 + ACL)
コンパイル:
ruby -w -c _filename_
実行:
ruby --yjit _filename_
結果
AC  
実行時間 62 ms / 1,000 ms
+ 333µs
コード長 231 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 12 ms
コンパイル使用メモリ 9,736 KB
実行使用メモリ 14,464 KB
最終ジャッジ日時 2026-11-12 12:19:28
合計ジャッジ時間 1,870 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #
raw source code

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