結果

問題 No.1015 おつりは要らないです
ユーザー tonyu0tonyu0
提出日時 2020-04-03 22:50:26
言語 Rust
(1.77.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 1,790 bytes
コンパイル時間 13,586 ms
コンパイル使用メモリ 379,340 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 01:17:32
合計ジャッジ時間 15,895 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut z: i64 = itr.next().unwrap().parse().unwrap();
    let mut y: i64 = itr.next().unwrap().parse().unwrap();
    let mut x: i64 = itr.next().unwrap().parse().unwrap();
    let mut a: std::collections::BinaryHeap<i64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    while let Some(mut b) = a.pop() {
        if b < 0 {
            println!("Yes");
            return;
        } else if x == 0 && y == 0 && z == 0 {
            println!("No");
            return;
        }
        if x > 0 {
            if b / 10000 <= x {
                x -= b / 10000;
                if b < 10000 {
                    x -= 1;
                    b = -1;
                } else {
                    b %= 10000;
                }
            } else {
                b -= x * 10000;
                x = 0;
            }
        } else if y > 0 {
            if b / 5000 <= y {
                y -= b / 5000;
                if b < 5000 {
                    y -= 1;
                    b = -1;
                } else {
                    b %= 5000;
                }
            } else {
                b -= y * 5000;
                y = 0;
            }
        } else if z > 0 {
            if b / 1000 <= z {
                z -= b / 1000;
                if b < 1000 {
                    z -= 1;
                    b = -1;
                } else {
                    b %= 1000;
                }
            } else {
                b -= z * 1000;
                z = 0;
            }
        }
        a.push(b);
    }
}
0