結果

問題 No.185 和風
ユーザー 小指が強い人
提出日時 2015-11-10 00:36:52
言語 Ruby
(3.4.1)
結果
AC  
実行時間 98 ms / 1,000 ms
コード長 313 bytes
コンパイル時間 54 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-09-13 14:17:23
合計ジャッジ時間 1,247 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:7: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:14: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

n = gets.to_i
bef = -1
n.times do |i|
    a = gets.split.map(&:to_i)
    d = a[1].to_i - a[0].to_i
    if d <= 0
        puts -1
        exit
    else
        if bef == -1
            bef = d
        end    
        if d != bef
            puts -1
            exit
        end
        bef = d
    end
end
puts bef
0