結果

問題 No.733 分身並列コーディング
ユーザー 0w10w1
提出日時 2018-09-09 00:53:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 1,500 ms
コード長 702 bytes
コンパイル時間 2,041 ms
コンパイル使用メモリ 204,376 KB
実行使用メモリ 16,708 KB
最終ジャッジ日時 2023-08-23 11:50:16
合計ジャッジ時間 5,480 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 49 ms
16,304 KB
testcase_04 AC 48 ms
16,340 KB
testcase_05 AC 49 ms
16,344 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 49 ms
16,708 KB
testcase_08 AC 47 ms
16,496 KB
testcase_09 AC 24 ms
9,700 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 12 ms
6,536 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 25 ms
9,820 KB
testcase_20 AC 24 ms
9,552 KB
testcase_21 AC 12 ms
6,496 KB
testcase_22 AC 48 ms
16,684 KB
testcase_23 AC 12 ms
6,384 KB
testcase_24 AC 12 ms
6,652 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 49 ms
16,356 KB
testcase_29 AC 49 ms
16,156 KB
testcase_30 AC 49 ms
16,260 KB
testcase_31 AC 49 ms
16,188 KB
testcase_32 AC 6 ms
4,636 KB
testcase_33 AC 6 ms
4,768 KB
testcase_34 AC 6 ms
4,612 KB
testcase_35 AC 7 ms
4,616 KB
testcase_36 AC 6 ms
4,612 KB
testcase_37 AC 6 ms
4,768 KB
testcase_38 AC 49 ms
16,360 KB
testcase_39 AC 48 ms
16,408 KB
testcase_40 AC 49 ms
16,400 KB
testcase_41 AC 7 ms
4,596 KB
testcase_42 AC 7 ms
4,672 KB
testcase_43 AC 7 ms
4,596 KB
testcase_44 AC 49 ms
16,168 KB
testcase_45 AC 50 ms
16,432 KB
testcase_46 AC 48 ms
16,384 KB
testcase_47 AC 48 ms
16,520 KB
testcase_48 AC 48 ms
16,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

signed main() {
  ios::sync_with_stdio(false);

  int T;
  cin >> T;

  int N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];

  vector<vector<int>> dp(1 << N, vector<int>(N + 1, 0x3f3f3f3f));
  dp[0][0] = 0;
  for (int s = 0; s < 1 << N; ++s) {
    for (int i = 0; i < N; ++i) if (dp[s][i] <= T) dp[s][i + 1] = 0;
    for (int i = 0; i < N; ++i) {
      if (s >> i & 1) continue;
      for (int j = 0; j <= N; ++j)
        dp[s | 1 << i][j] = min(dp[s | 1 << i][j], dp[s][j] + A[i]);
    }
  }

  int all = (1 << N) - 1;
  int ans = find(dp[all].begin(), dp[all].end(), 0) - dp[all].begin();
  cout << ans << endl;
}
        
0