結果

問題 No.1782 ManyCoins
ユーザー SSRSSSRS
提出日時 2021-12-11 00:06:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 993 bytes
コンパイル時間 1,601 ms
コンパイル使用メモリ 174,968 KB
実行使用メモリ 47,040 KB
最終ジャッジ日時 2023-09-26 00:07:41
合計ジャッジ時間 5,901 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 10 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 141 ms
15,336 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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++){
    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;
    for (int j = 0; j < W[0]; j++){
      pq.push(make_pair(dp[j], j));
    }
    vector<bool> used(W[0], false);
    while (!pq.empty()){
      long long x = pq.top().first;
      int v = pq.top().second;
      pq.pop();
      if (!used[v]){
        used[v] = true;
        long long y = x + W[i];
        int w = (v + W[i]) % W[0];
        if (dp[w] > y){
          dp[w] = y;
          pq.push(make_pair(y, w));
        }
      }
    }
  }
  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;
}
0