結果

問題 No.1782 ManyCoins
ユーザー PachicobuePachicobue
提出日時 2021-12-11 17:34:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,245 bytes
コンパイル時間 2,136 ms
コンパイル使用メモリ 205,780 KB
実行使用メモリ 11,452 KB
最終ジャッジ日時 2023-09-27 05:45:19
合計ジャッジ時間 4,862 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 WA -
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 11 ms
4,380 KB
testcase_16 AC 29 ms
5,416 KB
testcase_17 AC 33 ms
6,492 KB
testcase_18 AC 33 ms
5,632 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 13 ms
4,728 KB
testcase_21 AC 6 ms
4,380 KB
testcase_22 AC 16 ms
4,744 KB
testcase_23 AC 41 ms
6,664 KB
testcase_24 AC 5 ms
11,184 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 36 ms
5,708 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 6 ms
11,248 KB
testcase_29 AC 31 ms
11,372 KB
testcase_30 AC 21 ms
11,236 KB
testcase_31 AC 29 ms
11,452 KB
testcase_32 AC 32 ms
11,444 KB
testcase_33 AC 47 ms
11,228 KB
testcase_34 AC 49 ms
11,232 KB
testcase_35 AC 57 ms
11,424 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 4 ms
9,552 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 1 ms
4,380 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 5 ms
11,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using u64 = unsigned long long;
constexpr uint NMAX = 20;
constexpr uint WMAX = 1000000;
constexpr u64 INF = 1ULL << 60;
u64 dp[WMAX];
uint Ws[NMAX];
uint ws[NMAX];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    uint N;
    u64 L;
    std::cin >> N >> L;
    for (uint i = 0; i < N; i++) {
        std::cin >> Ws[i];
    }
    std::sort(Ws, Ws + N);
    const uint W = Ws[0];
    for (uint i = 1; i < N; i++) {
        ws[i] = Ws[i] % W;
    }
    std::fill(dp, dp + W, INF);
    dp[0] = 0;
    using P = std::pair<u64, uint>;
    std::priority_queue<P, std::vector<P>, std::greater<P>> Q;
    Q.push({0, 0});
    while (not Q.empty()) {
        const auto [c, w] = Q.top();
        Q.pop();
        if (dp[w] < c) { continue; }
        for (uint i = 1; i < N; i++) {
            uint nw = (w + ws[i]);
            if (nw >= W) { nw -= W; }
            const u64 ndp = c + Ws[i];
            if (dp[nw] > ndp) {
                Q.push({ndp, nw});
                dp[nw] = ndp;
            }
        }
    }
    u64 ans = 0;
    for (uint w = 0; w < W; w++) {
        if (dp[w] > L) { break; }
        ans += (L - dp[w]) / W + 1;
    }
    std::cout << ans - 1 << "\n";
    return 0;
}
0