結果
問題 |
No.733 分身並列コーディング
|
ユーザー |
|
提出日時 | 2019-07-05 16:12:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 199 ms / 1,500 ms |
コード長 | 643 bytes |
コンパイル時間 | 874 ms |
コンパイル使用メモリ | 70,708 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-21 20:43:59 |
合計ジャッジ時間 | 6,329 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include <iostream> #include <vector> using namespace std; int main(void) { constexpr int inf = 987'654'321; int T, N; scanf("%d%d", &T, &N); vector<int> t(N); for(int i=0; i<N; ++i) { scanf("%d", &t[i]); } // dp[問題の集合] := 最小人数 vector<int> dp(1<<N, inf); for(int S0=0; S0<1<<N; ++S0) { int acc = 0; for(int i=0; i<N; ++i) { if(S0 >> i & 1) { acc += t[i]; } } if(acc <= T) { dp[S0] = 1; } } for(int S0=0; S0<1<<N; ++S0) { for(int T0=S0; T0; T0=--T0 & S0) { dp[S0] = min(dp[S0], dp[S0 & ~T0] + dp[T0]); } } int res = dp[(1<<N)-1]; printf("%d\n", res); return 0; }