結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
48,904 KB
testcase_01 AC 43 ms
48,980 KB
testcase_02 AC 44 ms
48,748 KB
testcase_03 AC 43 ms
49,020 KB
testcase_04 AC 44 ms
48,732 KB
testcase_05 WA -
testcase_06 AC 43 ms
48,732 KB
testcase_07 AC 43 ms
48,904 KB
testcase_08 AC 44 ms
46,836 KB
testcase_09 AC 44 ms
48,832 KB
testcase_10 AC 294 ms
63,844 KB
testcase_11 AC 309 ms
63,848 KB
testcase_12 AC 299 ms
63,880 KB
testcase_13 AC 303 ms
63,276 KB
testcase_14 AC 295 ms
63,136 KB
testcase_15 AC 294 ms
61,740 KB
testcase_16 AC 308 ms
63,516 KB
testcase_17 AC 299 ms
64,612 KB
testcase_18 AC 300 ms
63,576 KB
testcase_19 AC 298 ms
63,284 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,748 KB
testcase_31 AC 175 ms
60,448 KB
testcase_32 AC 183 ms
60,672 KB
testcase_33 AC 299 ms
64,944 KB
testcase_34 AC 44 ms
48,884 KB
testcase_35 WA -
testcase_36 AC 44 ms
49,104 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 % 5000 / 1000 + 1;
			o.y = o.a % 10000 / 5000;
			o.z = o.a / 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