結果

問題 No.842 初詣
ユーザー iwa_choco_168iwa_choco_168
提出日時 2019-12-09 20:52:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 660 bytes
コンパイル時間 2,945 ms
コンパイル使用メモリ 72,092 KB
実行使用メモリ 56,152 KB
最終ジャッジ日時 2023-09-05 09:42:46
合計ジャッジ時間 6,819 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,672 KB
testcase_01 AC 118 ms
55,676 KB
testcase_02 AC 119 ms
55,820 KB
testcase_03 AC 116 ms
55,864 KB
testcase_04 AC 118 ms
55,900 KB
testcase_05 AC 117 ms
55,644 KB
testcase_06 AC 117 ms
55,696 KB
testcase_07 AC 118 ms
55,700 KB
testcase_08 AC 117 ms
56,152 KB
testcase_09 AC 117 ms
55,860 KB
testcase_10 AC 117 ms
55,736 KB
testcase_11 AC 117 ms
55,628 KB
testcase_12 AC 118 ms
55,920 KB
testcase_13 AC 116 ms
55,696 KB
testcase_14 AC 118 ms
55,964 KB
testcase_15 AC 119 ms
56,080 KB
testcase_16 AC 119 ms
56,016 KB
testcase_17 AC 119 ms
55,540 KB
testcase_18 AC 122 ms
55,884 KB
testcase_19 AC 120 ms
55,776 KB
testcase_20 AC 119 ms
55,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] coin = new int[6];
        for(int i = 0; i < 6; i++) coin[i] = Integer.parseInt(sc.next());
        int[] money = {500, 100, 50, 10, 5, 1};
        int x = Integer.parseInt(sc.next());
        boolean flag = false;
        int temp;
        for(int i = 0; i < 6; i++) {
            temp = Math.min(coin[i], x / money[i]);
            x -= temp * money[i];
            if(x == 0) {
                flag = true;
                break;
            }
        }
        System.out.println((flag)? "YES" : "NO");
    }
}
0