結果

問題 No.1015 おつりは要らないです
ユーザー hayatosumhayatosum
提出日時 2020-04-10 09:51:16
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,082 bytes
コンパイル時間 3,529 ms
コンパイル使用メモリ 78,984 KB
実行使用メモリ 74,768 KB
最終ジャッジ日時 2023-10-12 19:18:59
合計ジャッジ時間 47,596 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,524 KB
testcase_01 AC 120 ms
55,912 KB
testcase_02 AC 118 ms
55,568 KB
testcase_03 AC 119 ms
55,752 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 122 ms
55,936 KB
testcase_08 AC 121 ms
55,604 KB
testcase_09 AC 121 ms
55,880 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
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 120 ms
55,632 KB
testcase_31 AC 369 ms
60,608 KB
testcase_32 AC 376 ms
60,216 KB
testcase_33 TLE -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 119 ms
55,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        int z = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        boolean judge = true;

        for (int price : a) {
            int count = (int) Math.ceil((price + 1) / 1000.0);
            while (0 < count) {
                if (10 <= count) {
                    if (1 <= z) {
                        z--;
                    } else if (2 <= y) {
                        y -= 2;
                    } else if (1 <= y && 5 <= x) {
                        y--;
                        x -= 5;
                    } else if (10 <= x) {
                        x -= 10;
                    } else {
                        judge = false;
                        break;
                    }
                    count -= 10;
                } else if (5 <= count) {
                    if (1 <= y) {
                        y--;
                    } else if (5 <= x) {
                        x -= 5;
                    } else if (1 <= z) {
                        z--;
                    } else {
                        judge = false;
                        break;
                    }
                    count -= 5;
                } else {
                    if (count <= x) {
                        x -= count;
                    } else if (1 <= y) {
                        y--;
                    } else if (1 <= z) {
                        z--;
                    } else {
                        judge = false;
                        break;
                    }
                    count = 0;
                }
            }
        }

        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }
}
0