結果
| 問題 |
No.1782 ManyCoins
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-12-11 00:13:17 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,324 bytes |
| コンパイル時間 | 3,255 ms |
| コンパイル使用メモリ | 114,912 KB |
| 最終ジャッジ日時 | 2025-01-26 07:33:36 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 WA * 5 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(n); i++)
int N;
i64 L;
int Z;
vector<i64> W;
vector<int> dp;
int main() {
cin >> N;
cin >> L;
W.resize(N);
rep(i,N) cin >> W[i];
sort(W.begin(), W.end());
Z = W.back(); W.pop_back();
dp.assign(Z, Z+100); dp[0] = 0;
for(i64 w : W){
vector<vector<int>> queues(Z+1);
rep(i,Z) if(dp[i] <= Z) queues[dp[i]].push_back(i);
w %= Z;
rep(pred,Z){
rep(i, queues[pred].size()){
int p = queues[pred][i];
if(dp[p] != pred) continue;
int nxp = (p + w);
int nxd = pred;
if(nxp >= Z){ nxp -= Z; nxd++; }
if(dp[nxp] <= nxd) continue;
dp[nxp] = nxd;
queues[nxd].push_back(nxp);
}
}
}
i64 ans = L;
rep(i,Z){
i64 U = (L + Z - i) / Z;
if(i == 0) U--;
ans -= min<i64>(U, dp[i]);
}
cout << ans << endl;
return 0;
}
struct ios_do_not_sync{
ios_do_not_sync(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
} ios_do_not_sync_instance;
Nachia