結果

問題 No.2856 Junk Market Game
コンテスト
ユーザー QiToY
提出日時 2024-08-25 14:34:22
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,059 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 12,013 ms
コンパイル使用メモリ 200,660 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-04-03 22:44:21
合計ジャッジ時間 12,379 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#![allow(unused_imports)]

fn main() {
    input! {
        n: usize,
        a: [i64; 2*n],
        b: [i64; 2*n],
    }
    let mut c: Vec<_> = std::iter::zip(a, b).collect();
    c.sort_by_key(|(a, b)| a + b);
    let mut ans = 0;
    for (i, (a, b)) in c.into_iter().enumerate() {
        ans += if i % 2 == 0 { a } else { -b };
    }
    println!("{ans}");
}

/*

*/

use proconio::{input, marker::*};
use std::{cmp::Reverse, collections::*};

#[macro_export]
macro_rules! chmax {
    ($a:expr, $b:expr) => {{
        let tmp = $b;
        if $a < tmp {
            $a = tmp;
            true
        } else {
            false
        }
    }};
}

#[macro_export]
macro_rules! chmin {
    ($a:expr, $b:expr) => {{
        let tmp = $b;
        if $a > tmp {
            $a = tmp;
            true
        } else {
            false
        }
    }};
}

#[macro_export]
/// mvec![]
macro_rules! mvec {
    ($val:expr; ()) => {
        $val
    };
    ($val:expr; ($size:expr $(,$rest:expr)*)) => {
        vec![mvec![$val; ($($rest),*)]; $size]
    };
}
0