結果

問題 No.842 初詣
ユーザー tentententen
提出日時 2020-08-31 23:06:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 3,018 ms
コンパイル使用メモリ 74,508 KB
実行使用メモリ 41,384 KB
最終ジャッジ日時 2024-04-28 11:29:42
合計ジャッジ時間 6,179 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,016 KB
testcase_01 AC 132 ms
41,056 KB
testcase_02 AC 130 ms
41,048 KB
testcase_03 AC 133 ms
41,260 KB
testcase_04 AC 132 ms
41,008 KB
testcase_05 AC 134 ms
40,888 KB
testcase_06 AC 135 ms
41,112 KB
testcase_07 AC 132 ms
41,384 KB
testcase_08 AC 134 ms
41,152 KB
testcase_09 AC 135 ms
40,876 KB
testcase_10 AC 133 ms
40,956 KB
testcase_11 AC 136 ms
41,152 KB
testcase_12 AC 119 ms
40,132 KB
testcase_13 AC 118 ms
39,988 KB
testcase_14 AC 133 ms
41,056 KB
testcase_15 AC 132 ms
41,168 KB
testcase_16 AC 135 ms
41,140 KB
testcase_17 AC 131 ms
41,040 KB
testcase_18 AC 135 ms
40,828 KB
testcase_19 AC 134 ms
40,780 KB
testcase_20 AC 134 ms
40,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int[] values = new int[]{500, 100, 50, 10, 5, 1};
    	int[] counts = new int[6];
    	for (int i = 0; i < 6; i++) {
    	    counts[i] = sc.nextInt();
    	}
    	int total = sc.nextInt();
    	for (int i = 0; i < 6; i++) {
    	    int result = total / values[i];
    	    total -= Math.min(counts[i], result) * values[i];
    	}
    	if (total == 0) {
    	    System.out.println("YES");
    	} else {
    	    System.out.println("NO");
    	}
	}
}
0