結果
| 問題 |
No.1120 Strange Teacher
|
| コンテスト | |
| ユーザー |
Strorkis
|
| 提出日時 | 2020-07-22 22:51:53 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,417 bytes |
| コンパイル時間 | 14,007 ms |
| コンパイル使用メモリ | 382,032 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-22 23:53:16 |
| 合計ジャッジ時間 | 15,722 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 12 |
ソースコード
fn main() {
let n: usize = {
let mut buf = String::new();
std::io::stdin().read_line(&mut buf).unwrap();
buf.trim_end().parse().unwrap()
};
let a: Vec<i64> = {
let mut buf = String::new();
std::io::stdin().read_line(&mut buf).unwrap();
let iter = buf.split_whitespace();
iter.map(|x| x.parse().unwrap()).collect()
};
let b: Vec<i64> = {
let mut buf = String::new();
std::io::stdin().read_line(&mut buf).unwrap();
let iter = buf.split_whitespace();
iter.map(|x| x.parse().unwrap()).collect()
};
let mut c = vec![0; n];
for i in 0..n {
c[i] = a[i] - b[i];
}
c.sort();
let ans = {
if n == 2 {
let x = c[1] - c[0];
if x % 2 == 0 {
x / 2
} else {
-1
}
} else {
if (2..(n - 1)).fold(true, |acc, i| acc && c[i] == c[i + 1]) {
let x = c[2] - c[1];
if x % 2 == 0 {
let y = (c[2] + c[1]) / 2 - (c[0] - x / 2);
if y % 2 == 0 {
x / 2 + y / 2
} else {
-1
}
} else {
-1
}
} else {
-1
}
}
};
println!("{}", ans);
}
Strorkis