提出 #46692447


ソースコード 拡げる

use proconio::input;
use superslice::Ext;

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [i64; n],
        mut b: [i64; m],
    };
    b.sort();
    let mut min = (a[0] - b[0]).abs();
    for a_i in a {
        let r = b.lower_bound(&a_i);
        let l = r.saturating_sub(1);
        if let Some(b_r) = b.get(r) {
            min = min.min((b_r - a_i).abs());
        }
        if let Some(b_l) = b.get(l) {
            min = min.min((b_l - a_i).abs());
        }
    }
    let ans = min;
    println!("{}", ans);
}

提出情報

提出日時
問題 C - Min Difference
ユーザ bouzuya
言語 Rust (rustc 1.70.0)
得点 300
コード長 543 Byte
結果 AC
実行時間 50 ms
メモリ 9552 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 20
セット名 テストケース
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, small_00.txt, small_01.txt, small_02.txt, small_03.txt, small_04.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 1 ms 1928 KiB
example_01.txt AC 0 ms 1928 KiB
example_02.txt AC 0 ms 1864 KiB
hand_00.txt AC 12 ms 7692 KiB
hand_01.txt AC 16 ms 9348 KiB
random_00.txt AC 30 ms 9172 KiB
random_01.txt AC 30 ms 9380 KiB
random_02.txt AC 29 ms 9440 KiB
random_03.txt AC 50 ms 9508 KiB
random_04.txt AC 49 ms 9464 KiB
random_05.txt AC 50 ms 9496 KiB
random_06.txt AC 50 ms 9528 KiB
random_07.txt AC 49 ms 9500 KiB
random_08.txt AC 50 ms 9552 KiB
random_09.txt AC 50 ms 9484 KiB
small_00.txt AC 1 ms 2280 KiB
small_01.txt AC 1 ms 2116 KiB
small_02.txt AC 1 ms 2112 KiB
small_03.txt AC 2 ms 2040 KiB
small_04.txt AC 1 ms 1980 KiB