結果
問題 |
No.2835 Take and Flip
|
ユーザー |
![]() |
提出日時 | 2024-08-09 21:23:56 |
言語 | Rust (1.83.0 + proconio) |
結果 |
RE
|
実行時間 | - |
コード長 | 518 bytes |
コンパイル時間 | 13,845 ms |
コンパイル使用メモリ | 378,268 KB |
実行使用メモリ | 9,196 KB |
最終ジャッジ日時 | 2024-08-09 21:24:18 |
合計ジャッジ時間 | 15,682 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 4 RE * 18 |
ソースコード
#![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); }