結果

問題 No.1120 Strange Teacher
ユーザー phsplsphspls
提出日時 2020-07-23 16:37:04
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 828 bytes
コンパイル時間 800 ms
コンパイル使用メモリ 146,280 KB
実行使用メモリ 6,108 KB
最終ジャッジ日時 2023-09-05 22:25:01
合計ジャッジ時間 2,719 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 18 ms
6,096 KB
testcase_05 AC 17 ms
6,060 KB
testcase_06 AC 14 ms
5,980 KB
testcase_07 AC 16 ms
6,064 KB
testcase_08 AC 14 ms
6,024 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 19 ms
6,016 KB
testcase_11 AC 19 ms
6,084 KB
testcase_12 AC 18 ms
6,108 KB
testcase_13 AC 18 ms
6,052 KB
testcase_14 AC 19 ms
6,056 KB
testcase_15 AC 15 ms
6,068 KB
testcase_16 AC 18 ms
6,064 KB
testcase_17 AC 15 ms
6,020 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 13 ms
6,020 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 1 ms
4,504 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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