結果

問題 No.2835 Take and Flip
コンテスト
ユーザー northward
提出日時 2024-08-09 21:23:56
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
RE  
実行時間 -
コード長 518 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,793 ms
コンパイル使用メモリ 204,896 KB
実行使用メモリ 9,388 KB
最終ジャッジ日時 2026-04-03 20:24:58
合計ジャッジ時間 6,318 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 4 RE * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#![allow(non_snake_case)]
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        N: usize,
        A: [isize; N],
    }

    let mut ans = 0;
    let mut S = A.iter().cloned().collect::<std::collections::BTreeSet<_>>();

    for i in 0..N {
        if i % 2 == 0 {
            let m = S.pop_last().unwrap();
            ans += m;
        } else {
            let m = S.pop_last().unwrap();
            ans += -(-m);
        }
    }

    println!("{}", ans);
}
0