結果

問題 No.1782 ManyCoins
ユーザー chocoruskchocorusk
提出日時 2021-12-11 00:30:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 1,560 bytes
コンパイル時間 3,518 ms
コンパイル使用メモリ 191,548 KB
実行使用メモリ 10,672 KB
最終ジャッジ日時 2023-09-26 01:52:32
合計ジャッジ時間 6,804 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 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,376 KB
testcase_13 AC 25 ms
7,008 KB
testcase_14 AC 81 ms
8,748 KB
testcase_15 AC 47 ms
6,684 KB
testcase_16 AC 58 ms
7,460 KB
testcase_17 AC 83 ms
8,616 KB
testcase_18 AC 55 ms
7,720 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 78 ms
8,704 KB
testcase_21 AC 84 ms
9,060 KB
testcase_22 AC 105 ms
9,828 KB
testcase_23 AC 97 ms
9,016 KB
testcase_24 AC 5 ms
6,936 KB
testcase_25 AC 107 ms
9,908 KB
testcase_26 AC 45 ms
6,296 KB
testcase_27 AC 124 ms
10,672 KB
testcase_28 AC 5 ms
7,008 KB
testcase_29 AC 21 ms
7,020 KB
testcase_30 AC 24 ms
7,016 KB
testcase_31 AC 26 ms
6,960 KB
testcase_32 AC 27 ms
7,008 KB
testcase_33 AC 37 ms
6,928 KB
testcase_34 AC 46 ms
7,080 KB
testcase_35 AC 55 ms
6,932 KB
testcase_36 AC 10 ms
6,792 KB
testcase_37 AC 6 ms
6,676 KB
testcase_38 AC 5 ms
6,924 KB
testcase_39 AC 3 ms
4,380 KB
testcase_40 AC 5 ms
6,808 KB
testcase_41 AC 5 ms
5,900 KB
testcase_42 AC 5 ms
6,784 KB
testcase_43 AC 5 ms
5,956 KB
testcase_44 AC 5 ms
6,920 KB
testcase_45 AC 5 ms
6,816 KB
testcase_46 AC 3 ms
4,380 KB
testcase_47 AC 3 ms
4,384 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 5 ms
6,956 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;
        if(l-i<0) continue;
        ll r=(l-i)/w0;
        ans+=max(0ll, r-d[i]+1);
    }
    ans--;
    cout<<ans<<endl;
    return 0;
}
0