結果
| 問題 | 
                            No.1374 Absolute Game
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-10-08 10:49:23 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 575 bytes | 
| コンパイル時間 | 11,412 ms | 
| コンパイル使用メモリ | 379,512 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-06-22 10:28:16 | 
| 合計ジャッジ時間 | 13,406 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 3 WA * 23 | 
コンパイルメッセージ
warning: unused import: `std::collections::VecDeque` --> src/main.rs:1:5 | 1 | use std::collections::VecDeque; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
ソースコード
use std::collections::VecDeque;
fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut c = String::new();
    std::io::stdin().read_line(&mut c).ok();
    let mut c: Vec<isize> = c.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let summary = c.iter().sum::<isize>();
    c.sort();
    if summary < 0 { c.reverse(); }
    let a = c.iter().skip(n/2+n%2).sum::<isize>();
    let b = c.iter().take(n/2+n%2).sum::<isize>();
    println!("{}", a.abs() - b.abs());
}