結果

問題 No.1015 おつりは要らないです
ユーザー sca1lsca1l
提出日時 2020-07-20 23:23:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 670 ms / 2,000 ms
コード長 1,480 bytes
コンパイル時間 1,805 ms
コンパイル使用メモリ 78,516 KB
実行使用メモリ 61,052 KB
最終ジャッジ日時 2024-04-29 06:18:27
合計ジャッジ時間 17,448 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
53,908 KB
testcase_01 AC 106 ms
53,900 KB
testcase_02 AC 98 ms
53,000 KB
testcase_03 AC 95 ms
52,768 KB
testcase_04 AC 102 ms
53,836 KB
testcase_05 AC 107 ms
53,900 KB
testcase_06 AC 91 ms
52,880 KB
testcase_07 AC 102 ms
53,996 KB
testcase_08 AC 99 ms
53,368 KB
testcase_09 AC 101 ms
53,976 KB
testcase_10 AC 592 ms
59,992 KB
testcase_11 AC 670 ms
59,932 KB
testcase_12 AC 587 ms
60,008 KB
testcase_13 AC 610 ms
59,924 KB
testcase_14 AC 550 ms
59,752 KB
testcase_15 AC 564 ms
59,852 KB
testcase_16 AC 602 ms
59,480 KB
testcase_17 AC 630 ms
59,704 KB
testcase_18 AC 583 ms
60,396 KB
testcase_19 AC 627 ms
61,052 KB
testcase_20 AC 576 ms
59,732 KB
testcase_21 AC 566 ms
59,980 KB
testcase_22 AC 550 ms
59,564 KB
testcase_23 AC 584 ms
59,952 KB
testcase_24 AC 549 ms
59,532 KB
testcase_25 AC 558 ms
59,888 KB
testcase_26 AC 568 ms
59,608 KB
testcase_27 AC 547 ms
59,876 KB
testcase_28 AC 560 ms
59,972 KB
testcase_29 AC 526 ms
59,524 KB
testcase_30 AC 103 ms
53,740 KB
testcase_31 AC 424 ms
59,832 KB
testcase_32 AC 431 ms
59,216 KB
testcase_33 AC 479 ms
60,120 KB
testcase_34 AC 104 ms
54,136 KB
testcase_35 AC 101 ms
53,884 KB
testcase_36 AC 95 ms
52,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main{
    
    static final int MOD = (int)1e9+7;
    
    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());
        int[] c = {z, y, x};
        int[] d = {10000, 5000, 1000};
        
        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        for(int i=0; i<3; i++){
            rsort(a);
            for(int j=0; j<n; j++){
                int t = Math.max(a[j]/d[i], 0);
                t = Math.min(t, c[i]);
                a[j] -= t*d[i];
                c[i] -= t;
            }
            rsort(a);
            for(int j=0; j<n; j++){
                if(c[i] > 0 && a[j] >= 0){
                    c[i]--;
                    a[j] -= d[i];
                }
            }
        }
        
        boolean ans = true;
        for(int i=0; i<n; i++){
            if(a[i] >= 0){
                ans = false;
                break;
            }
        }
        
        System.out.println(ans ? "Yes" : "No");
    }
    
    public static void rsort(int[] a){
        Arrays.sort(a);
        for(int i=0; i<a.length/2; i++){
            int tmp = a[i];
            a[i] = a[a.length-1-i];
            a[a.length-1-i] = tmp;
        }
    }
}
0