結果

問題 No.1015 おつりは要らないです
ユーザー ks2mks2m
提出日時 2020-04-03 22:48:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,428 bytes
コンパイル時間 2,381 ms
コンパイル使用メモリ 75,096 KB
実行使用メモリ 66,064 KB
最終ジャッジ日時 2023-09-16 03:53:42
合計ジャッジ時間 11,281 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,256 KB
testcase_01 AC 42 ms
49,244 KB
testcase_02 AC 43 ms
49,308 KB
testcase_03 AC 43 ms
49,244 KB
testcase_04 AC 43 ms
49,672 KB
testcase_05 WA -
testcase_06 AC 44 ms
49,020 KB
testcase_07 AC 43 ms
49,296 KB
testcase_08 AC 43 ms
49,508 KB
testcase_09 AC 43 ms
49,240 KB
testcase_10 AC 287 ms
63,612 KB
testcase_11 AC 296 ms
63,876 KB
testcase_12 AC 300 ms
64,056 KB
testcase_13 AC 301 ms
64,020 KB
testcase_14 AC 300 ms
63,716 KB
testcase_15 AC 294 ms
63,732 KB
testcase_16 AC 301 ms
63,920 KB
testcase_17 AC 295 ms
63,604 KB
testcase_18 AC 297 ms
63,984 KB
testcase_19 AC 300 ms
64,040 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 44 ms
49,132 KB
testcase_31 AC 179 ms
62,844 KB
testcase_32 AC 179 ms
61,120 KB
testcase_33 AC 255 ms
64,716 KB
testcase_34 AC 44 ms
49,140 KB
testcase_35 WA -
testcase_36 AC 44 ms
49,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int x = Integer.parseInt(sa[1]);
		int y = Integer.parseInt(sa[2]);
		int z = Integer.parseInt(sa[3]);
		sa = br.readLine().split(" ");
		Obj[] arr = new Obj[n];
		for (int i = 0; i < n; i++) {
			Obj o = new Obj();
			o.a = Integer.parseInt(sa[i]);
			o.x = (o.a / 1000 + 1) % 5;
			o.y = ((o.a + 1000) / 5000) % 2;
			o.z = (o.a + 1000) / 10000;
			arr[i] = o;
		}
		br.close();

		Arrays.parallelSort(arr);

		for (int i = 0; i < n; i++) {
			int v = Math.min(arr[i].x, x);
			arr[i].x -= v;
			x -= v;
			if (arr[i].x > 0) {
				arr[i].y++;
			}
		}

		if (x != 0) {
			y += x / 5;
		}

		for (int i = 0; i < n; i++) {
			int v = Math.min(arr[i].y, y);
			arr[i].y -= v;
			y -= v;
			if (arr[i].y > 0) {
				arr[i].z++;
			}
		}

		if (y != 0) {
			z += y / 2;
		}

		for (int i = 0; i < n; i++) {
			z -= arr[i].z;
			if (z < 0) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}

	static class Obj implements Comparable<Obj> {
		int a, x, y, z;

		@Override
		public int compareTo(Obj o) {
			if (x != o.x) {
				return x - o.x;
			}
			return y - o.y;
		}
	}
}
0