結果
問題 | No.733 分身並列コーディング |
ユーザー |
![]() |
提出日時 | 2020-03-07 02:18:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 1,500 ms |
コード長 | 717 bytes |
コンパイル時間 | 706 ms |
コンパイル使用メモリ | 71,928 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-14 11:05:18 |
合計ジャッジ時間 | 2,659 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; template<class t> inline bool chmin(t& a, t b) { if (a > b) { a = b; return 1; } return 0; } template<class T> T ceil(T a, T b) { return a / b + !!(a % b); } int main() { int T, n; cin >> T >> n; vector<int> t(n); for (auto &ti: t) cin >> ti; vector<int> dp(1 << n, T * n); dp[0] = 0; for (int mask = 0; mask < 1 << n; mask++) { int rem = T - dp[mask] % T; for (int i = 0; i < n; i++) if (!(mask >> i & 1)) { int add = t[i] <= rem ? t[i] : rem + t[i]; chmin(dp[mask ^ (1 << i)], dp[mask] + add); } } cout << ceil(dp[(1 << n) - 1], T) << endl; return 0; }