結果
問題 | No.2835 Take and Flip |
ユーザー | naut3 |
提出日時 | 2024-08-09 21:23:56 |
言語 | Rust (1.77.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 518 bytes |
コンパイル時間 | 13,845 ms |
コンパイル使用メモリ | 378,268 KB |
実行使用メモリ | 9,196 KB |
最終ジャッジ日時 | 2024-08-09 21:24:18 |
合計ジャッジ時間 | 15,682 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | AC | 1 ms
5,376 KB |
testcase_16 | RE | - |
testcase_17 | AC | 4 ms
5,376 KB |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
ソースコード
#![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); }