結果
| 問題 | No.1782 ManyCoins |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-05 13:56:34 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 282 ms / 2,000 ms |
| コード長 | 1,035 bytes |
| 記録 | |
| コンパイル時間 | 5,755 ms |
| コンパイル使用メモリ | 207,272 KB |
| 実行使用メモリ | 26,792 KB |
| 最終ジャッジ日時 | 2026-02-05 13:56:45 |
| 合計ジャッジ時間 | 6,208 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 48 |
ソースコード
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <unordered_map>
using namespace std;
using ll = long long;
int main() {
int N;ll L;cin >> N >> L;
vector<int> W(N);
for (int i =0 ;i < N;i++) cin >> W[i];
int w = W[0];
ll inf = (1LL << 60);
vector<ll> dist(w, inf);
dist[0] = 0;
priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>> > pq;
pq.push({0, 0});
while (!pq.empty()) {
auto tp = pq.top();
ll d = tp.first;
int v = tp.second;
pq.pop();
if (dist[v] < d) continue;
for (int t = 0;t < N;t++) {
int nv = (v + W[t]) % w;
ll ncst = dist[v] + W[t];
if (ncst < dist[nv]) {
dist[nv] = ncst;
pq.push({ncst, nv});
}
}
}
ll res = 0;
for (int k = 0;k < w;k++) {
//1 <= k+(wx) <= L
if (dist[k] > L) continue;
ll t = (L - dist[k]) / w;
if (dist[k] == 0) {
res += t;
} else {
res +=t + 1;
}
}
cout << res << endl;
}