結果

問題 No.1782 ManyCoins
ユーザー kiyoshi0205kiyoshi0205
提出日時 2021-12-11 09:55:48
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,497 ms / 2,000 ms
コード長 655 bytes
コンパイル時間 2,327 ms
コンパイル使用メモリ 205,840 KB
実行使用メモリ 15,748 KB
最終ジャッジ日時 2023-09-26 16:00:22
合計ジャッジ時間 9,206 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 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 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 18 ms
9,052 KB
testcase_14 AC 53 ms
4,464 KB
testcase_15 AC 48 ms
4,384 KB
testcase_16 AC 149 ms
7,412 KB
testcase_17 AC 194 ms
11,260 KB
testcase_18 AC 154 ms
7,396 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 65 ms
5,536 KB
testcase_21 AC 32 ms
4,380 KB
testcase_22 AC 109 ms
8,540 KB
testcase_23 AC 398 ms
15,748 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 7 ms
4,376 KB
testcase_26 AC 187 ms
8,504 KB
testcase_27 AC 6 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 39 ms
12,148 KB
testcase_30 AC 56 ms
12,200 KB
testcase_31 AC 87 ms
12,132 KB
testcase_32 AC 117 ms
12,220 KB
testcase_33 AC 536 ms
12,240 KB
testcase_34 AC 1,000 ms
12,400 KB
testcase_35 AC 1,497 ms
12,140 KB
testcase_36 AC 8 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 1 ms
4,384 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 1 ms
4,380 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(int i=0;i<N;++i)
int N,w[20],d;
ll L,dp[1000000],ans;
bool vis[1000000];
int main(){
  cin.tie(0)->sync_with_stdio(0);
  cin>>N>>L;
  rep(i,N){
    cin>>w[i];
    d=gcd(d,w[i]);
  }
  L/=d;
  rep(i,N)w[i]/=d;
  sort(w,w+N);
  priority_queue<ll,vector<ll>,greater<ll>> que;
  que.emplace(0);
  while(!que.empty()){
    ll x=que.top();que.pop();
    int a=x%w[0];
    if(vis[a])continue;
    vis[a]=true;
    dp[a]=x;
    rep(i,N)if(!vis[(a+w[i])%w[0]])que.emplace(x+w[i]);
  }
  rep(i,w[0]){
    if(L<dp[i])continue;
    ans+=(L-dp[i])/w[0]+1;
  }
  cout<<ans-1<<'\n';
}
0