結果

問題 No.989 N×Mマス計算(K以上)
コンテスト
ユーザー cra77756176
提出日時 2022-12-24 19:50:15
言語 Rust
(1.99.0 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
WJ  
(最新)
AC  
(最初)
実行時間 -
コード長 1,056 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
最終ジャッジ日時 2026-10-15 20:46:36
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)

ソースコード

diff #
raw source code

fn main() {
    let mut xx = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut xx).ok();
    let xx: Vec<&str> = xx.split_whitespace().collect();

    let m: usize = xx[1].parse().unwrap();
    let k: u64 = xx[2].parse().unwrap();
    let mut bb: Vec<u64> = xx[4..4 + m].iter().map(|&s| s.parse().unwrap()).collect();
    let mut aa: Vec<u64> = xx[4 + m..].iter().map(|&s| s.parse().unwrap()).collect();

    let op = match xx.get(3) {
        Some(&"+") => |a, b| a + b,
        Some(&"*") => |a, b| a * b,
        _ => unreachable!(),
    };

    aa.sort_unstable();
    bb.sort_unstable();
    aa.reverse();
    bb.reverse();

    let mut answer = 0;
    let mut left = 0;
    let mut right = bb.len();
    for &a in &aa {
        while left < right {
            let center = (left + right) / 2;
            if op(a, bb[center]) >= k {
                left = center + 1;
            } else {
                right = center;
            }
        }
        answer += left;
        left = 0;
    }

    println!("{answer}");
}
0