結果

問題 No.467 隠されていたゲーム
ユーザー GrenacheGrenache
提出日時 2016-12-17 11:34:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,328 bytes
コンパイル時間 3,885 ms
コンパイル使用メモリ 79,508 KB
実行使用メモリ 97,388 KB
最終ジャッジ日時 2024-05-08 04:03:56
合計ジャッジ時間 10,834 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
54,328 KB
testcase_01 AC 137 ms
53,948 KB
testcase_02 AC 137 ms
54,216 KB
testcase_03 AC 135 ms
54,216 KB
testcase_04 AC 139 ms
54,300 KB
testcase_05 AC 139 ms
54,372 KB
testcase_06 AC 137 ms
54,456 KB
testcase_07 AC 136 ms
54,520 KB
testcase_08 AC 137 ms
54,368 KB
testcase_09 AC 136 ms
54,380 KB
testcase_10 AC 136 ms
53,964 KB
testcase_11 AC 135 ms
54,492 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder467 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] d = new int[n];
		for (int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);
		int maxd = d[n - 1];

		int x = Math.abs(sc.nextInt());
		int y = Math.abs(sc.nextInt());
		int maxx = Math.max(x, y);

		if (maxx % maxd == 0) {
			pr.println(maxx / maxd);
			return;
		} else {
			int cnt = maxx / maxd;
			Set<Long> hs = new HashSet<>();
			Set<Long> hstmp = new HashSet<>();
			for (int e : d) {
				hs.add((long)e);
			}

			for (int i = 0; i <= cnt; i++) {
				if (hs.contains((long)(maxx - maxd * (cnt - i)))) {
					pr.println(cnt + 1);
					return;
				}

				hstmp.clear();
				for (long e : hs) {
					for (int e1 : d) {
						hstmp.add(e + e1);
					}
				}
				hs.addAll(hstmp);
			}

			if (x != y) {
				pr.println(maxx / maxd + 2);
			} else {
				pr.println(maxx / maxd + 2 + 2);
			}
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0