結果

問題 No.1015 おつりは要らないです
ユーザー fukafukatanifukafukatani
提出日時 2020-04-03 21:39:32
言語 Rust
(1.72.1)
結果
WA  
実行時間 -
コード長 1,779 bytes
コンパイル時間 1,007 ms
コンパイル使用メモリ 150,000 KB
実行使用メモリ 6,344 KB
最終ジャッジ日時 2023-09-16 00:40:56
合計ジャッジ時間 5,925 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 9 ms
4,380 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 8 ms
4,376 KB
testcase_13 AC 9 ms
4,380 KB
testcase_14 AC 8 ms
4,376 KB
testcase_15 AC 9 ms
4,376 KB
testcase_16 AC 9 ms
4,376 KB
testcase_17 AC 8 ms
4,376 KB
testcase_18 AC 8 ms
4,380 KB
testcase_19 AC 9 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 5 ms
4,380 KB
testcase_32 AC 5 ms
4,376 KB
testcase_33 AC 8 ms
4,376 KB
testcase_34 AC 0 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, mut x, mut y, mut z) = (v[0] as usize, v[1], v[2], v[3]);
    let mut a = read_vec::<i64>()
        .into_iter()
        .map(|x| x + 1)
        .collect::<Vec<_>>();

    for i in 0..n {
        let zi = a[i] / 10000;
        let act_z = min(z, zi);
        a[i] -= act_z * 10000;
        z -= act_z;

        let yi = a[i] / 5000;
        let act_y = min(y, yi);
        a[i] -= act_y * 5000;
        y -= act_y;
    }
    // debug!(a, x, y, z);

    while z > 0 {
        a.sort();
        a.reverse();
        for i in 0..n {
            if a[i] > 0 && z > 0 {
                a[i] -= 10000;
                z -= 1;
            }
        }
    }

    while y > 0 {
        a.sort();
        a.reverse();
        for i in 0..n {
            if a[i] > 0 && y > 0 {
                a[i] -= 5000;
                y -= 1;
            }
        }
    }

    for num in a {
        if num > 0 {
            x -= (1000 + num - 1) / 1000;
        }
    }
    if x >= 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
0