結果

問題 No.1015 おつりは要らないです
ユーザー kusagame12kusagame12
提出日時 2023-11-25 17:32:36
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,876 bytes
コンパイル時間 2,431 ms
コンパイル使用メモリ 77,368 KB
実行使用メモリ 73,192 KB
最終ジャッジ日時 2023-11-25 17:32:47
合計ジャッジ時間 11,583 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
61,060 KB
testcase_01 AC 54 ms
54,128 KB
testcase_02 AC 54 ms
54,136 KB
testcase_03 AC 55 ms
54,144 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 56 ms
54,120 KB
testcase_07 AC 56 ms
54,100 KB
testcase_08 AC 56 ms
54,136 KB
testcase_09 AC 55 ms
54,156 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 276 ms
64,628 KB
testcase_16 AC 266 ms
64,576 KB
testcase_17 AC 276 ms
65,020 KB
testcase_18 AC 274 ms
65,080 KB
testcase_19 AC 306 ms
64,688 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int x = Integer.parseInt(str[1]);
        int y = Integer.parseInt(str[2]);
        int z = Integer.parseInt(str[3]);
        
        String[] as = br.readLine().split(" ");
        int[] prices = new int[n];
        for(int i = 0 ; i < n ; i++){
            prices[i] = Integer.parseInt(as[i]);
        }
        
        Arrays.sort(prices);
        
        if(x + y + z < n){
            System.out.print("No");
            return;
        }
    
        int cnt = 0;
        for(int i = n - 1 ; i >= 0 ; i--){
            int price = prices[i];
            for(int j = 0 ; j <= z ; j++){
                for(int k = 0 ; k <= y ; k++){
                    for(int l = 0 ; l <= x ; l++){
                        long sum = j * 10000 + k * 5000 + l * 1000;
                        if(sum > price){
                        //System.out.println(sum+":"+price+"   x:"+x+" j:"+j+" y:"+y+" k:"+k+" z:"+z+" l:"+l);
                            cnt++;
                            z = z-j;
                            y = y-k;
                            x = x-l;
                            if(j != 0){
                                j--;
                            }
                            if(k != 0){
                                k--;
                            }
                            if(l != 0){
                                l--;
                            }
                            break;
                        }
                    }
                }
            }
        }
        
        System.out.print(cnt >= n ? "Yes" : "No");

    }

}
0