結果

問題 No.1015 おつりは要らないです
ユーザー tzyvrntzyvrn
提出日時 2020-04-03 23:52:17
言語 Rust
(1.77.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 1,623 bytes
コンパイル時間 12,908 ms
コンパイル使用メモリ 377,216 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 01:21:59
合計ジャッジ時間 14,861 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

use std::cmp::min;
//{{{
#[allow(unused_macros)]
macro_rules! getl {
    ( $( $t:ty ),* ) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let s = s.trim_end();
            let mut ws = s.split_whitespace();
            ($(ws.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! getl_vec {
    ( $t:ty ) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let s = s.trim_end();
            s.split_whitespace().map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    };
}
//}}}

fn main() {
    let (n, x, y, z) = getl!(usize, i64, i64, i64);
    let mut a = getl_vec!(i64);

    for i in 0..n {
        a[i] += 1;
    }

    let mut z = z;
    for i in 0..n {
        let q = min(a[i] / 10000, z);
        z -= q;
        a[i] -= 10000 * q;
    }
    a.sort();
    a.reverse();
    for i in 0..n {
        if a[i] == 0 {
            break;
        }
        if z > 0 {
            z -= 1;
            a[i] = 0;
        }
    }

    let mut y = y;
    for i in 0..n {
        let q = min(a[i] / 5000, y);
        y -= q;
        a[i] -= 5000 * q;
    }
    a.sort();
    a.reverse();
    for i in 0..n {
        if a[i] == 0 {
            break;
        }
        if y > 0 {
            y -= 1;
            a[i] = 0;
        }
    }

    let mut x = x;
    for i in 0..n {
        let q = (a[i] + 1000 - 1) / 1000;
        x -= q;
    }

    if x >= 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}
0