結果

問題 No.1782 ManyCoins
ユーザー chocoruskchocorusk
提出日時 2021-12-11 00:28:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,532 bytes
コンパイル時間 3,537 ms
コンパイル使用メモリ 191,788 KB
実行使用メモリ 10,688 KB
最終ジャッジ日時 2023-09-26 01:50:24
合計ジャッジ時間 6,730 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 25 ms
7,232 KB
testcase_14 AC 77 ms
9,120 KB
testcase_15 AC 44 ms
6,632 KB
testcase_16 AC 53 ms
7,416 KB
testcase_17 AC 82 ms
8,772 KB
testcase_18 AC 55 ms
8,076 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 77 ms
8,608 KB
testcase_21 AC 88 ms
9,200 KB
testcase_22 AC 108 ms
9,864 KB
testcase_23 AC 95 ms
8,964 KB
testcase_24 AC 4 ms
7,016 KB
testcase_25 AC 105 ms
9,884 KB
testcase_26 AC 43 ms
6,172 KB
testcase_27 AC 124 ms
10,688 KB
testcase_28 AC 5 ms
7,072 KB
testcase_29 AC 21 ms
6,932 KB
testcase_30 AC 23 ms
6,892 KB
testcase_31 AC 24 ms
6,928 KB
testcase_32 AC 27 ms
7,116 KB
testcase_33 AC 38 ms
6,968 KB
testcase_34 AC 50 ms
6,948 KB
testcase_35 AC 61 ms
7,076 KB
testcase_36 AC 10 ms
6,672 KB
testcase_37 AC 6 ms
6,748 KB
testcase_38 AC 5 ms
7,084 KB
testcase_39 AC 3 ms
4,380 KB
testcase_40 AC 4 ms
6,772 KB
testcase_41 AC 5 ms
5,936 KB
testcase_42 AC 5 ms
6,552 KB
testcase_43 AC 4 ms
5,904 KB
testcase_44 AC 5 ms
7,016 KB
testcase_45 AC 4 ms
6,468 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 5 ms
7,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint998244353;

int main()
{
    int n; ll l;
    cin>>n>>l;
    int w[22];
    for(int i=0; i<n; i++) cin>>w[i];
    sort(w, w+n, greater<int>());
    int w0=w[0];
    const int INF=1e9;
    vector<int> d(w0, INF);
    d[0]=0;
    deque<int> deq;
    deq.push_back(0);
    while(!deq.empty()){
        int x=deq.front();
        deq.pop_front();
        for(int i=1; i<n; i++){
            if(x+w[i]<w0){
                if(d[x+w[i]]>d[x]){
                    d[x+w[i]]=d[x];
                    deq.push_front(x+w[i]);
                }
            }else{
                if(d[x+w[i]-w0]>d[x]+1){
                    d[x+w[i]-w0]=d[x]+1;
                    deq.push_back(x+w[i]-w0);
                }
            }
        }
    }
    ll ans=0;
    for(int i=0; i<w0; i++){
        if(d[i]==INF)continue;
        ll r=(l-i)/w0;
        ans+=max(0ll, r-d[i]+1);
    }
    ans--;
    cout<<ans<<endl;
    return 0;
}
0