結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  naut3 | 
| 提出日時 | 2024-11-14 19:59:29 | 
| 言語 | Rust (1.83.0 + proconio) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,086 bytes | 
| コンパイル時間 | 13,746 ms | 
| コンパイル使用メモリ | 380,296 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-14 19:59:44 | 
| 合計ジャッジ時間 | 14,413 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 21 WA * 2 | 
ソースコード
#![allow(non_snake_case, unused_must_use, unused_imports)]
use std::io::{self, prelude::*};
fn main() {
    let (stdin, stdout) = (io::read_to_string(io::stdin()).unwrap(), io::stdout());
    let (mut stdin, mut buffer) = (stdin.split_whitespace(), io::BufWriter::new(stdout.lock()));
    macro_rules! input {
        ($t: tt, $n: expr) => {
            (0..$n).map(|_| input!($t)).collect::<Vec<_>>()
        };
        (Chars) => {
            input!(String).chars().collect::<Vec<_>>()
        };
        (Usize1) => {
            stdin.next().unwrap().parse::<usize>().unwrap() - 1
        };
        ($t: ty) => {
            stdin.next().unwrap().parse::<$t>().unwrap()
        };
    }
    let N = input!(usize);
    let W = input!(u32, N);
    let mut hq = std::collections::BinaryHeap::from_iter(W.into_iter());
    while hq.len() >= 2 {
        let a = hq.pop().unwrap();
        let b = hq.pop().unwrap();
        hq.push(a - b);
    }
    if hq.pop().unwrap() == 0 {
        writeln!(buffer, "possible");
    } else {
        writeln!(buffer, "impossible");
    }
}
            
            
            
        