結果

問題 No.1782 ManyCoins
ユーザー HIR180HIR180
提出日時 2021-12-11 00:20:26
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 3,450 ms
コンパイル使用メモリ 210,964 KB
実行使用メモリ 11,024 KB
最終ジャッジ日時 2023-09-26 01:27:13
合計ジャッジ時間 5,533 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 20 ms
6,396 KB
testcase_14 AC 12 ms
4,380 KB
testcase_15 AC 15 ms
4,376 KB
testcase_16 AC 38 ms
5,328 KB
testcase_17 AC 44 ms
6,352 KB
testcase_18 AC 44 ms
5,600 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 17 ms
4,572 KB
testcase_21 AC 9 ms
4,376 KB
testcase_22 AC 21 ms
4,388 KB
testcase_23 AC 57 ms
6,444 KB
testcase_24 AC 6 ms
10,980 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 47 ms
5,828 KB
testcase_27 AC 3 ms
4,380 KB
testcase_28 AC 6 ms
10,824 KB
testcase_29 AC 29 ms
10,764 KB
testcase_30 AC 26 ms
10,764 KB
testcase_31 AC 36 ms
11,024 KB
testcase_32 AC 41 ms
10,716 KB
testcase_33 AC 70 ms
10,892 KB
testcase_34 AC 85 ms
10,776 KB
testcase_35 AC 108 ms
10,840 KB
testcase_36 AC 5 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 3 ms
4,376 KB
testcase_41 AC 3 ms
4,508 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 5 ms
9,056 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 3 ms
4,376 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 6 ms
10,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
	int n; long long L; cin >> n >> L;
	vector<int>w(n); 
	for(int i=0;i<n;i++) cin >> w[i];
	
	sort(w.begin(), w.end());
	vector<long long>dp(w[0], 1e18);
	dp[0] = 0;
	priority_queue<pair<long long, int>>que;
	que.emplace(0, 0);
	
	while(!que.empty()){
		auto q = que.top(); que.pop();
		long long zan = -q.first;
		int v = q.second;
		if(dp[v] != zan) continue;
		
		for(int i=1;i<n;i++){
			if(dp[(w[i]+v)%w[0]] > zan+w[i]){
				dp[(w[i]+v)%w[0]] = zan+w[i];
				que.emplace(-zan-w[i], (w[i]+v)%w[0]);
			}
		}
	}
	long long ans = 0;
	for(int i=0;i<w[0];i++) if(dp[i] <= L) ans += (L-dp[i]) / w[0] + 1;
	cout << --ans << '\n';
}
0