結果

問題 No.1015 おつりは要らないです
ユーザー ntk3264ntk3264
提出日時 2020-04-04 14:59:22
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,383 bytes
コンパイル時間 2,391 ms
コンパイル使用メモリ 74,208 KB
実行使用メモリ 63,296 KB
最終ジャッジ日時 2023-09-16 05:42:50
合計ジャッジ時間 20,549 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
56,028 KB
testcase_01 AC 134 ms
55,720 KB
testcase_02 AC 129 ms
55,584 KB
testcase_03 AC 127 ms
55,544 KB
testcase_04 WA -
testcase_05 AC 126 ms
55,924 KB
testcase_06 AC 128 ms
55,596 KB
testcase_07 AC 129 ms
55,604 KB
testcase_08 AC 126 ms
55,580 KB
testcase_09 AC 128 ms
55,572 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 628 ms
60,948 KB
testcase_16 AC 697 ms
61,204 KB
testcase_17 AC 648 ms
61,064 KB
testcase_18 AC 647 ms
61,904 KB
testcase_19 AC 653 ms
60,804 KB
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 127 ms
55,720 KB
testcase_31 AC 471 ms
60,704 KB
testcase_32 AC 488 ms
60,560 KB
testcase_33 AC 615 ms
61,092 KB
testcase_34 AC 130 ms
55,556 KB
testcase_35 AC 130 ms
56,176 KB
testcase_36 AC 131 ms
55,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
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();

        Arrays.sort(arr);

        label:
        for (int i=0; i<n; i++) {
            int price = arr[i];
            int div = price / 1000;

            if (div==0) {
                if (x>0) {
                    x--;
                    continue label;
                } else if (y>0) {
                    y--;
                    continue label;
                } else if (z>0) {
                    z--;
                    continue label;
                } else if (z<=0) {
                    System.out.print("No");
                    return;
                }
            } else if (1<=div) {
                if (0<price && price<5000) {
                    y--;
                    continue label;
                } else if (5000<=price) {
                    int tmp = price / 5000;
                    if (x>=div+1) {
                        x -= (div+1);
                    } else {
                        price -= x*1000;
                        x = 0;
                    }
                    if (y>=tmp+1) {
                        y -= (tmp+1);
                        continue label;
                    } else {
                        price -= y*5000;
                        y = 0;
                        if (price<=0) continue label;
                    }
                }
                if (5000<=price) {
                    if (price<10000) {
                        z--;
                        continue label;
                    } else {
                        int tmp = price / 10000;
                        if (z>=tmp+1) {
                            z -= (tmp+1);
                            continue label;
                        } else {
                            System.out.print("No");
//                            System.out.print("here");

                            return;
                        }
                    }
                }
            }

        }

        System.out.print("Yes");


    }

}
0