結果
| 問題 | No.602 隠されていたゲーム2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-03 12:45:45 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,929 bytes |
| 記録 | |
| コンパイル時間 | 20,912 ms |
| コンパイル使用メモリ | 377,716 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-28 08:57:23 |
| 合計ジャッジ時間 | 14,822 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 13 |
コンパイルメッセージ
warning: unused variable: `n` --> src/main.rs:83:9 | 83 | let n = get!(usize); | ^ help: if this is intentional, prefix it with an underscore: `_n` | = note: `#[warn(unused_variables)]` on by default
ソースコード
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;
mod util {
use std::io::stdin;
use std::str::FromStr;
use std::fmt::Debug;
#[allow(dead_code)]
pub fn line() -> String {
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
line.trim().to_string()
}
#[allow(dead_code)]
pub fn gets<T: FromStr>() -> Vec<T>
where
<T as FromStr>::Err: Debug,
{
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
line.split_whitespace()
.map(|t| t.parse().unwrap())
.collect()
}
}
#[allow(unused_macros)]
macro_rules! get {
($t:ty) => {
{
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
line.trim().parse::<$t>().unwrap()
}
};
($($t:ty),*) => {
{
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
let mut iter = line.split_whitespace();
(
$(iter.next().unwrap().parse::<$t>().unwrap(),)*
)
}
};
($t:ty; $n:expr) => {
(0..$n).map(|_|
get!($t)
).collect::<Vec<_>>()
};
($($t:ty),*; $n:expr) => {
(0..$n).map(|_|
get!($($t),*)
).collect::<Vec<_>>()
};
($t:ty ;;) => {
{
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
line.split_whitespace()
.map(|t| t.parse::<$t>().unwrap())
.collect::<Vec<_>>()
}
};
}
#[allow(unused_macros)]
macro_rules! debug {
($($a:expr),*) => {
println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
}
}
fn main() {
let n = get!(usize);
let ds = get!(i64;;);
let (x, y) = get!(i64, i64);
let mut heaps = vec![BinaryHeap::new(); 2];
for &d in &ds {
heaps[(d % 2) as usize].push(d);
}
let z = x.abs() + y.abs();
if z == 0 {
println!("0");
return;
}
if ds.iter().any(|&d| d >= z && (d - z) % 2 == 0) {
println!("1");
return;
}
if z % 2 == 0 {
if heaps[0].pop().unwrap_or(0) + heaps[0].pop().unwrap_or(0) >= z ||
heaps[1].pop().unwrap_or(0) + heaps[1].pop().unwrap_or(0) >= z
{
println!("2");
} else {
println!("-1");
}
} else {
if heaps[0].pop().unwrap_or(0) + heaps[1].pop().unwrap_or(0) >= z {
println!("2");
} else {
println!("-1");
}
}
}