結果

問題 No.1015 おつりは要らないです
ユーザー ntk3264ntk3264
提出日時 2020-04-04 15:44:33
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,067 bytes
コンパイル時間 2,162 ms
コンパイル使用メモリ 74,312 KB
実行使用メモリ 63,132 KB
最終ジャッジ日時 2023-09-16 05:43:36
合計ジャッジ時間 20,674 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
56,156 KB
testcase_01 AC 128 ms
55,812 KB
testcase_02 AC 131 ms
56,004 KB
testcase_03 AC 134 ms
55,764 KB
testcase_04 AC 129 ms
55,948 KB
testcase_05 AC 128 ms
53,796 KB
testcase_06 AC 129 ms
55,788 KB
testcase_07 AC 130 ms
55,544 KB
testcase_08 WA -
testcase_09 AC 127 ms
53,472 KB
testcase_10 AC 653 ms
62,688 KB
testcase_11 AC 672 ms
63,132 KB
testcase_12 AC 667 ms
60,840 KB
testcase_13 AC 647 ms
62,816 KB
testcase_14 AC 691 ms
62,840 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 653 ms
60,864 KB
testcase_21 AC 622 ms
62,548 KB
testcase_22 AC 652 ms
58,904 KB
testcase_23 AC 620 ms
60,696 KB
testcase_24 AC 664 ms
61,572 KB
testcase_25 AC 645 ms
60,760 KB
testcase_26 AC 648 ms
61,192 KB
testcase_27 AC 690 ms
61,116 KB
testcase_28 AC 644 ms
61,100 KB
testcase_29 AC 635 ms
62,348 KB
testcase_30 AC 129 ms
55,496 KB
testcase_31 AC 474 ms
61,512 KB
testcase_32 AC 472 ms
60,756 KB
testcase_33 AC 617 ms
61,240 KB
testcase_34 AC 127 ms
55,844 KB
testcase_35 AC 126 ms
55,772 KB
testcase_36 AC 127 ms
55,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();

        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();

        int max = 0;

        label:
        for (int i=0; i<n; i++) {
            if (z<=0) break label;
            if (arr[i]>=10000) {
                int cnt = arr[i]/10000;
                int remain = arr[i]%10000;
                z -= cnt;
                arr[i] -= cnt*10000;
                if (remain==0) arr[i] += 1;
            }
        }
        Arrays.sort(arr);
        if (z>0) {
            label:
            for (int i=n-1; i>=0; i--) {
                arr[i] = 0;
                z--;
                if (z<=0) break label;
            }
        }

        label:
        for (int i=0; i<n; i++) {
            if (y<=0) break label;
            if (arr[i]>=5000) {
                int cnt = arr[i]/5000;
                int remain = arr[i]%5000;
                y -= cnt;
                arr[i] -= cnt*5000;
                if (remain==0) arr[i] += 1;
            }
        }
        Arrays.sort(arr);
        if (y>0) {
            label:
            for (int i=n-1; i>=0; i--) {
                arr[i] = 0;
                y--;
                if (y<=0) break label;
            }
        }

        label:
        for (int i=0; i<n; i++) {
            if (x<=0) break label;
            int cnt = arr[i]/1000;
            if (arr[i]!=0) x -= (cnt+1);
            arr[i] = 0;
        }

        int cnt = 0;
        for (int i=0; i<n; i++) {
            if (arr[i]==0) cnt++;
        }

//        for (int i=0; i<n; i++) {
//            System.out.println(arr[i]);
//        }

//        System.out.println("cnt" +cnt);

        if (cnt==n) {
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }


    }

}
0