結果

問題 No.185 和風
コンテスト
ユーザー Lycoris_i
提出日時 2015-09-06 18:25:36
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
AC  
実行時間 54 ms / 1,000 ms
コード長 231 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 124 ms
コンパイル使用メモリ 8,960 KB
実行使用メモリ 29,952 KB
最終ジャッジ日時 2026-04-02 14:13:59
合計ジャッジ時間 916 ms
ジャッジサーバーID
(参考情報)
judge5_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:7: warning: ambiguous first argument; put parentheses or a space even after `-` operator
Main.rb:11: warning: ambiguous first argument; put parentheses or a space even after `-` operator
Syntax OK

ソースコード

diff #
raw source code

n = gets.to_i
x = Array.new
y = Array.new
n.times {|i|
  x[i], y[i] = gets.split(" ").map(&:to_i)
  if y[i] - x[i] < 1
    puts -1
    exit
  end
  if y[i] - x[i] != y[i - 1] - x[i - 1]
    puts -1
    exit
  end
}
puts y[0] - x[0]
0