結果

問題 No.1015 おつりは要らないです
ユーザー soywater
提出日時 2020-04-03 22:42:15
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,162 bytes
コンパイル時間 2,716 ms
コンパイル使用メモリ 76,788 KB
実行使用メモリ 61,428 KB
最終ジャッジ日時 2024-07-03 05:03:20
合計ジャッジ時間 7,590 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 5 WA * 1 TLE * 1 -- * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		int less = -1;
		int ans[] = new int[3];

		int[] list = new int[N];

		for (int i = 0; i < N; i++) {
			list[i] = sc.nextInt();
			ans[0]=0;
			ans[1]=0;
			ans[2]=0;
			less = 0;

			//1000&5000&10000
			for (int c = 0; c <= X; c++) {
				for (int d = 0; d <= Y; d++) {
					for (int e = 0; e <= Z; e++) {
						if (1000 * c + 5000 * d + 10000 * e > list[i]) {
							if(less == 0) {
								less = 1000 * c + 5000 * d + 10000 * e;
								ans[0] = c;
								ans[1] = d;
								ans[2] = e;
								break;
							}else {
								if (less > 1000 * c + 5000 * d + 10000 * e) {
									less = 1000 * c + 5000 * d + 10000 * e;
									ans[0] = c;
									ans[1] = d;
									ans[2] = e;
									break;
								}
							}
						}
					}
				}
			}

			if(less == 0) {
				System.out.println("No");
				break;
			}

			X = X - ans[0];
			Y = Y - ans[1];
			Z = Z - ans[2];
		}

		if(less != 0) {
		System.out.println("Yes");
		}
	}
}
0