結果

問題 No.1015 おつりは要らないです
ユーザー ntk3264ntk3264
提出日時 2020-04-04 15:34:04
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,052 bytes
コンパイル時間 2,043 ms
コンパイル使用メモリ 76,772 KB
実行使用メモリ 63,052 KB
最終ジャッジ日時 2023-09-16 05:43:12
合計ジャッジ時間 19,786 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,588 KB
testcase_01 AC 121 ms
55,652 KB
testcase_02 AC 122 ms
55,848 KB
testcase_03 AC 124 ms
55,380 KB
testcase_04 AC 125 ms
55,948 KB
testcase_05 WA -
testcase_06 AC 125 ms
55,912 KB
testcase_07 AC 125 ms
56,508 KB
testcase_08 AC 124 ms
55,696 KB
testcase_09 AC 123 ms
55,628 KB
testcase_10 AC 640 ms
61,936 KB
testcase_11 AC 634 ms
62,788 KB
testcase_12 AC 659 ms
59,328 KB
testcase_13 AC 629 ms
62,504 KB
testcase_14 AC 672 ms
62,604 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 122 ms
55,624 KB
testcase_31 WA -
testcase_32 AC 487 ms
60,612 KB
testcase_33 AC 581 ms
61,036 KB
testcase_34 AC 123 ms
55,872 KB
testcase_35 AC 123 ms
55,960 KB
testcase_36 AC 123 ms
56,360 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;
            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