結果
問題 | No.1120 Strange Teacher |
ユーザー |
|
提出日時 | 2024-09-19 22:04:28 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 773 bytes |
コンパイル時間 | 11,932 ms |
コンパイル使用メモリ | 388,080 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-19 22:04:44 |
合計ジャッジ時間 | 13,698 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 1 |
ソースコード
use proconio::input;fn main() {input! {n:usize,a:[i64;n],b:[i64;n],}if n == 2 {let ans = if a[0] - b[0] + a[1] - b[1] == 0 {(a[0] - b[0]).abs()} else {-1};println!("{}", ans);return;}let a_sum = a.iter().sum::<i64>();let b_sum = b.iter().sum::<i64>();let f1 = (0..n).all(|i| (a[i] - b[i]).abs() % 2 == (a[0] - b[0]).abs() % 2);let f2 = a_sum >= b_sum;let f3 = (a_sum - b_sum) % (n - 2) as i64 == 0;let f4 = (0..n).all(|i| (a[i] - b[i]).abs() <= (a_sum - b_sum) / (n - 2) as i64);let ans = if f1 && f2 && f3 && f4 {(a_sum - b_sum) / (n - 2) as i64} else {-1};println!("{}", ans);}