結果

問題 No.1782 ManyCoins
ユーザー SSRSSSRS
提出日時 2021-12-11 00:08:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,021 bytes
コンパイル時間 1,686 ms
コンパイル使用メモリ 178,548 KB
実行使用メモリ 47,508 KB
最終ジャッジ日時 2023-09-26 00:36:00
合計ジャッジ時間 15,402 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 10 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 137 ms
15,116 KB
testcase_14 AC 135 ms
5,248 KB
testcase_15 AC 123 ms
5,648 KB
testcase_16 AC 445 ms
12,076 KB
testcase_17 AC 533 ms
11,836 KB
testcase_18 AC 429 ms
12,296 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 152 ms
5,300 KB
testcase_21 AC 74 ms
4,500 KB
testcase_22 AC 240 ms
5,392 KB
testcase_23 AC 876 ms
11,180 KB
testcase_24 AC 5 ms
10,776 KB
testcase_25 AC 11 ms
4,376 KB
testcase_26 AC 542 ms
12,428 KB
testcase_27 AC 10 ms
4,380 KB
testcase_28 AC 5 ms
10,828 KB
testcase_29 AC 258 ms
27,428 KB
testcase_30 AC 545 ms
42,844 KB
testcase_31 AC 836 ms
42,940 KB
testcase_32 AC 1,153 ms
43,000 KB
testcase_33 TLE -
testcase_34 TLE -
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];
  }
  sort(W.begin(), W.end());
  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