結果
| 問題 | No.1782 ManyCoins | 
| コンテスト | |
| ユーザー |  SSRS | 
| 提出日時 | 2021-12-11 00:07:30 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 804 bytes | 
| コンパイル時間 | 1,711 ms | 
| コンパイル使用メモリ | 175,440 KB | 
| 実行使用メモリ | 32,084 KB | 
| 最終ジャッジ日時 | 2024-07-18 19:44:55 | 
| 合計ジャッジ時間 | 17,634 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 4 WA * 27 TLE * 2 -- * 15 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000000;
int main(){
  int N;
  long long L;
  cin >> N >> L;
  vector<int> W(N);
  for (int i = 0; i < N; i++){
    cin >> W[i];
  }
  vector<long long> dp(W[0], INF);
  dp[0] = 0;
  for (int i = 1; i < N; i++){
    vector<pair<long long, int>> P(W[0]);
    for (int j = 0; j < W[0]; j++){
      P[j] = make_pair(dp[j], j);
    }
    sort(P.begin(), P.end());
    for (int j = 0; j < W[0]; j++){
      int v = P[j].second;
      long long x = dp[v];
      long long y = x + W[i];
      int w = (v + W[i]) % W[0];
      if (dp[w] > y){
        dp[w] = y;
      }
    }
  }
  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 - 1 << endl;
}
            
            
            
        