結果
問題 | No.1120 Strange Teacher |
ユーザー |
![]() |
提出日時 | 2020-07-22 21:44:35 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 170 ms / 1,000 ms |
コード長 | 380 bytes |
コンパイル時間 | 140 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 26,880 KB |
最終ジャッジ日時 | 2024-06-22 15:06:27 |
合計ジャッジ時間 | 5,010 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
コンパイルメッセージ
Main.rb:7: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
n = readline.to_ia = readline.split.map(&:to_i)b = readline.split.map(&:to_i)sa = a.sumsb = b.sumif sa < sb || (n == 2 && sa != sb) || (n > 2 && (sa - sb) % (n - 2) != 0)puts -1elseif n == 2puts (a[0] - b[0]).abselsec = (sa - sb) / (n - 2)a = a.map { |v| v - c }puts (0...n).any? { |i| a[i] > b[i] || (b[i] - a[i]) % 2 != 0 } ? -1 : cendend