結果
問題 | No.288 貯金箱の仕事 |
ユーザー | Pachicobue |
提出日時 | 2018-12-08 16:33:53 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 960 bytes |
コンパイル時間 | 2,009 ms |
コンパイル使用メモリ | 203,500 KB |
実行使用メモリ | 9,640 KB |
最終ジャッジ日時 | 2023-10-12 04:59:02 |
合計ジャッジ時間 | 10,036 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 1 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,348 KB |
testcase_03 | WA | - |
testcase_04 | AC | 1 ms
4,348 KB |
testcase_05 | AC | 2 ms
4,348 KB |
testcase_06 | AC | 2 ms
4,348 KB |
testcase_07 | RE | - |
testcase_08 | WA | - |
testcase_09 | RE | - |
testcase_10 | WA | - |
testcase_11 | RE | - |
testcase_12 | WA | - |
testcase_13 | RE | - |
testcase_14 | WA | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | AC | 1 ms
4,352 KB |
testcase_18 | RE | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | AC | 3 ms
4,348 KB |
testcase_26 | AC | 4 ms
4,348 KB |
testcase_27 | AC | 3 ms
4,348 KB |
testcase_28 | WA | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | RE | - |
testcase_43 | AC | 34 ms
6,052 KB |
testcase_44 | RE | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | RE | - |
testcase_49 | AC | 66 ms
9,640 KB |
testcase_50 | RE | - |
testcase_51 | RE | - |
testcase_52 | RE | - |
testcase_53 | RE | - |
testcase_54 | RE | - |
testcase_55 | AC | 2 ms
4,352 KB |
ソースコード
#include <bits/stdc++.h> #define show(x) std::cerr << #x << " = " << x << std::endl using ll = long long; int main() { int N; ll M; std::cin >> N >> M; std::vector<int> A(N); std::vector<ll> K(N); for (int i = 0; i < N; i++) { std::cin >> A[i]; } int max = 0; for (int i = 0; i < N; i++) { std::cin >> K[i], M -= K[i] * A[i], max = std::max(max, A[i]); } ll ans = std::max(0LL, M - max * max) / max; M = ans * max - M; std::vector<int> memo(max * max, max); auto dp = [&](auto&& self, const ll M) -> int { if (M == 0) { return 0; } if (M < 0) { return max; } if (memo[M] != max) { return memo[M]; } int ans = max; for (const ll a : A) { ans = std::min(ans, self(self, M - a)); } return memo[M] = ans + 1; }; const int add = dp(dp, M); if (add >= max) { return std::cout << -1 << std::endl, 0; } std::cout << ans + add << std::endl; return 0; }