結果

問題 No.1015 おつりは要らないです
ユーザー ntk3264ntk3264
提出日時 2020-04-04 16:30:33
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,153 bytes
コンパイル時間 2,305 ms
コンパイル使用メモリ 73,900 KB
実行使用メモリ 64,064 KB
最終ジャッジ日時 2023-09-16 05:47:06
合計ジャッジ時間 20,624 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,840 KB
testcase_01 AC 132 ms
55,612 KB
testcase_02 AC 125 ms
55,840 KB
testcase_03 AC 124 ms
55,656 KB
testcase_04 AC 126 ms
55,792 KB
testcase_05 AC 128 ms
55,832 KB
testcase_06 AC 126 ms
55,656 KB
testcase_07 AC 127 ms
55,908 KB
testcase_08 WA -
testcase_09 AC 127 ms
55,900 KB
testcase_10 AC 664 ms
62,712 KB
testcase_11 AC 663 ms
62,900 KB
testcase_12 AC 684 ms
60,424 KB
testcase_13 AC 655 ms
63,396 KB
testcase_14 AC 684 ms
64,064 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 656 ms
60,992 KB
testcase_21 AC 636 ms
61,576 KB
testcase_22 AC 653 ms
60,648 KB
testcase_23 AC 616 ms
60,996 KB
testcase_24 AC 656 ms
61,320 KB
testcase_25 AC 645 ms
60,864 KB
testcase_26 AC 649 ms
61,072 KB
testcase_27 AC 684 ms
61,524 KB
testcase_28 AC 654 ms
60,960 KB
testcase_29 AC 615 ms
62,780 KB
testcase_30 AC 127 ms
55,444 KB
testcase_31 AC 465 ms
59,976 KB
testcase_32 AC 480 ms
60,824 KB
testcase_33 WA -
testcase_34 AC 128 ms
55,872 KB
testcase_35 AC 127 ms
55,872 KB
testcase_36 AC 127 ms
55,680 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();
        long x = sc.nextLong();
        long y = sc.nextLong();
        long z = sc.nextLong();

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

        int max = 0;

        label:
        for (int i=0; i<n; i++) {
            if (z==0) break label;
            if (arr[i]>=10000) {
                long cnt = arr[i]/10000;
                long remain = arr[i]%10000;
                if (z<cnt) cnt = z;
                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) {
                long cnt = arr[i]/5000;
                long remain = arr[i]%5000;
                if (y<cnt) y = cnt;
                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;
            long 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