結果
問題 |
No.733 分身並列コーディング
|
ユーザー |
|
提出日時 | 2018-09-09 00:53:31 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 61 ms / 1,500 ms |
コード長 | 702 bytes |
コンパイル時間 | 1,791 ms |
コンパイル使用メモリ | 199,012 KB |
最終ジャッジ日時 | 2025-01-06 13:14:10 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#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; }