結果
問題 |
No.1120 Strange Teacher
|
ユーザー |
![]() |
提出日時 | 2020-07-23 08:30:29 |
言語 | Ruby (3.4.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 324 bytes |
コンパイル時間 | 300 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 26,752 KB |
最終ジャッジ日時 | 2024-06-23 16:27:45 |
合計ジャッジ時間 | 5,464 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 RE * 3 |
コンパイルメッセージ
Main.rb:7: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:13: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
n = gets.to_i a = gets.split.map &:to_i b = gets.split.map &:to_i minus = a.sum - b.sum if minus % (n - 2) != 0 puts -1 exit end cnt = minus / (n - 2) a = a.map { |i| i -= cnt } if (0...n).any? { |i| a[i] > b[i] || (b[i] - a[i]) % 2 == 1 } puts -1 exit end puts (0...n).sum { |i| (b[i] - a[i]) / 2 } == cnt ? cnt : -1