結果
問題 | No.733 分身並列コーディング |
ユーザー |
![]() |
提出日時 | 2018-09-11 16:18:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 1,500 ms |
コード長 | 814 bytes |
コンパイル時間 | 594 ms |
コンパイル使用メモリ | 76,528 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 16:13:25 |
合計ジャッジ時間 | 2,162 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> using namespace std; using ll = long long; int main() { int T, n; cin >> T >> n; vector<int> t(n); for (int i = 0; i < n; i++) { cin >> t[i]; } vector<int> dp(1 << n); dp[0] = 0; for (int k = 1; k < 1 << n; k++) { int x = 1 << 30; for (int i = 0; i < n; i++) { int l = k ^ 1 << i; if (l < k) { int a = dp[l] + t[i]; int b = a & 0xffff; if (b >= T) a = (dp[l] & ~0xffff) + 0x10000 + (b > T) * t[i]; x = min(x, a); } } dp[k] = x; } cout << ((dp[(1 << n) - 1] + 0xffff) >> 16) << endl; return 0; }