結果

問題 No.1120 Strange Teacher
ユーザー phspls
提出日時 2020-07-23 16:37:04
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 828 bytes
コンパイル時間 12,239 ms
コンパイル使用メモリ 400,164 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-23 17:47:50
合計ジャッジ時間 13,680 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let a: Vec<isize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut b = String::new();
    std::io::stdin().read_line(&mut b).ok();
    let b: Vec<isize> = b.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut diffs: Vec<isize> = b.iter().zip(a.iter())
        .map(|ba| *ba.0 - *ba.1)
        .collect();
    diffs.sort();
    let mut count: isize = diffs[0] / -1isize;
    let result = count;
    for val in (1..n).map(|i| diffs[i]) {
        count -= (val - diffs[0]) / 2isize;
    }
    println!("{}", if count == 0isize { result } else { -1isize });
}
0