結果
| 問題 |
No.2835 Take and Flip
|
| コンテスト | |
| ユーザー |
naut3
|
| 提出日時 | 2024-08-09 21:25:40 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 69 ms / 2,000 ms |
| コード長 | 603 bytes |
| コンパイル時間 | 13,444 ms |
| コンパイル使用メモリ | 382,020 KB |
| 実行使用メモリ | 12,928 KB |
| 最終ジャッジ日時 | 2024-08-09 21:26:03 |
| 合計ジャッジ時間 | 15,822 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#![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 = {
let mut s = std::collections::BTreeSet::new();
for i in 0..N {
s.insert((A[i], i));
}
s
};
for i in 0..N {
if i % 2 == 0 {
let m = S.pop_last().unwrap().0;
ans += m;
} else {
let m = S.pop_last().unwrap().0;
ans += -(-m);
}
}
println!("{}", ans);
}
naut3