結果

問題 No.288 貯金箱の仕事
ユーザー maine_honzukimaine_honzuki
提出日時 2021-05-13 10:52:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 976 bytes
コンパイル時間 2,247 ms
コンパイル使用メモリ 204,692 KB
実行使用メモリ 12,632 KB
最終ジャッジ日時 2023-10-25 04:43:55
合計ジャッジ時間 16,044 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
12,372 KB
testcase_01 AC 16 ms
8,024 KB
testcase_02 AC 11 ms
8,024 KB
testcase_03 AC 5 ms
7,976 KB
testcase_04 WA -
testcase_05 AC 4 ms
8,024 KB
testcase_06 AC 4 ms
7,976 KB
testcase_07 AC 1,519 ms
8,024 KB
testcase_08 AC 114 ms
8,024 KB
testcase_09 AC 1,053 ms
8,024 KB
testcase_10 AC 317 ms
8,024 KB
testcase_11 AC 484 ms
8,024 KB
testcase_12 AC 297 ms
8,024 KB
testcase_13 AC 859 ms
8,024 KB
testcase_14 AC 269 ms
8,024 KB
testcase_15 AC 1,250 ms
8,024 KB
testcase_16 AC 996 ms
8,024 KB
testcase_17 AC 197 ms
8,024 KB
testcase_18 AC 520 ms
8,024 KB
testcase_19 AC 217 ms
8,024 KB
testcase_20 AC 121 ms
8,024 KB
testcase_21 AC 474 ms
8,024 KB
testcase_22 AC 1,024 ms
8,024 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

//https://ncode.syosetu.com/n4830bu/288/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N), K(N);
    for (auto&& a : A) {
        cin >> a;
    }
    for (auto&& k : K) {
        cin >> k;
    }
    M *= -1;
    for (int i = 0; i < N; i++) {
        M += A[i] * K[i];
    }
    vector<ll> dp(610000, (ll)1e18 + 10);
    dp[0] = 0;

    ll maine = 1;
    if (M > 0)
        while (M) {
            for (int i = 0; i < N; i++) {
                for (int x = 600000; x >= 0; x--) {
                    dp[x + A[i]] = min(dp[x + A[i]], dp[x] + maine);
                }
            }
            for (int i = 0; i < 300000; i++) {
                dp[i] = dp[i * 2 + M % 2ll];
            }
            fill(dp.begin() + 300000, dp.end(), (ll)1e18 + 10);
            M >>= 1;
            maine <<= 1;
        }
    else
        dp[0] = -1;

    cout << (dp[0] > (ll)1e18 ? -1 : dp[0]) << endl;
}
0