結果

問題 No.288 貯金箱の仕事
ユーザー pekempeypekempey
提出日時 2015-10-10 17:48:06
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,063 bytes
コンパイル時間 1,194 ms
コンパイル使用メモリ 144,516 KB
実行使用メモリ 5,396 KB
最終ジャッジ日時 2023-09-28 11:34:33
合計ジャッジ時間 3,643 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,280 KB
testcase_01 AC 4 ms
5,352 KB
testcase_02 AC 4 ms
5,268 KB
testcase_03 AC 4 ms
5,332 KB
testcase_04 AC 4 ms
5,396 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 22 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 197 ms
5,272 KB
testcase_24 AC 91 ms
5,268 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 198 ms
5,316 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 4 ms
5,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define GET_MACRO(a, b, c, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rep2(i, a) rep3 (i, 0, a)
#define rep3(i, a, b) for (int i = (a); i < (b); i++)
#define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__)
#define repr2(i, a) repr3 (i, 0, a)
#define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define chmin(a, b) ((b) < a && (a = (b), true))
#define chmax(a, b) (a < (b) && (a = (b), true))
using namespace std;
typedef long long ll;

const ll inf = 2e18;
const ll MX = 252525;
ll dp[MX], A[500], K[500];

int main() {
	int N, M;
	cin >> N >> M;
	rep (i, N) cin >> A[i];
	rep (i, N) cin >> K[i];
	ll sum = 0;
	rep (i, N) sum += A[i] * K[i];
	ll D = sum - M;
	if (D < 0) {
		cout << -1 << endl;
		return 0;
	}	
	rep (i, MX) dp[i] = inf;
	dp[0] = 0;
	rep (i, N) rep (j, A[i], MX) {
		chmin(dp[j], dp[j - A[i]] + 1);
	}
	ll mx = A[N - 1];
	ll num = max(0ll, (D - MX) / mx + 1);
	ll ans = dp[D - num * mx] + num;
	if (ans >= inf) ans = -1;
	cout << ans << endl;
	return 0;
}
0