結果
問題 | No.1015 おつりは要らないです |
ユーザー |
|
提出日時 | 2023-11-25 17:32:36 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,876 bytes |
コンパイル時間 | 2,434 ms |
コンパイル使用メモリ | 77,468 KB |
実行使用メモリ | 68,548 KB |
最終ジャッジ日時 | 2024-09-26 11:01:33 |
合計ジャッジ時間 | 10,985 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 9 WA * 7 TLE * 1 -- * 16 |
ソースコード
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");}}