結果

問題 No.842 初詣
ユーザー tsunabittsunabit
提出日時 2019-08-08 21:52:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 4,607 ms
コンパイル使用メモリ 72,120 KB
実行使用メモリ 56,092 KB
最終ジャッジ日時 2023-09-26 01:44:28
合計ジャッジ時間 8,789 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,488 KB
testcase_01 AC 123 ms
55,432 KB
testcase_02 AC 122 ms
55,992 KB
testcase_03 AC 122 ms
56,004 KB
testcase_04 AC 121 ms
55,400 KB
testcase_05 AC 122 ms
55,956 KB
testcase_06 AC 120 ms
56,004 KB
testcase_07 AC 122 ms
55,448 KB
testcase_08 AC 124 ms
55,784 KB
testcase_09 AC 124 ms
55,888 KB
testcase_10 AC 123 ms
55,724 KB
testcase_11 AC 121 ms
55,548 KB
testcase_12 AC 122 ms
55,672 KB
testcase_13 AC 121 ms
55,656 KB
testcase_14 AC 119 ms
55,796 KB
testcase_15 AC 121 ms
56,092 KB
testcase_16 AC 124 ms
55,516 KB
testcase_17 AC 120 ms
55,896 KB
testcase_18 AC 121 ms
56,064 KB
testcase_19 AC 122 ms
55,972 KB
testcase_20 AC 122 ms
55,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;

public class No842 {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String[] a = sc.nextLine().split(" ");
    	int[] k = new int[a.length];
    	for(int i = 0; i < a.length; i++) {
    		k[i] = Integer.parseInt(a[i]);
    	}
    	int[] coin = {500,100,50,10,5,1};
    	
    	boolean f = false;
    	for(int i = 0; i < 6; i++) {
    		while(k[6] >= coin[i] && k[i] != 0 && k[6] != 0) {
    			k[6] -= coin[i];
    			k[i] -= 1;
    		}
    		if(k[6] == 0) {
    			f = true;
    			break;
    		}
    	}
    	
    	if(f) System.out.println("YES");
    	else System.out.println("NO");
    }
}
0