結果
| 問題 |
No.733 分身並列コーディング
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2018-09-10 17:35:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 78 ms / 1,500 ms |
| コード長 | 1,104 bytes |
| コンパイル時間 | 963 ms |
| コンパイル使用メモリ | 79,344 KB |
| 実行使用メモリ | 16,640 KB |
| 最終ジャッジ日時 | 2024-12-30 05:07:45 |
| 合計ジャッジ時間 | 3,767 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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<vector<int>> dp(1 << n, vector<int>(n + 1));
for (int k = 0; k < 1 << n; k++) {
int x = 0;
for (int i = 0; i < n; i++) {
if (k & 1 << i) {
x += t[i];
}
}
dp[k][0] = x;
for (int j = 1; j <= n; j++) {
if (dp[k][j - 1] <= T) {
dp[k][j] = 0;
continue;
}
int x = 1 << 30;
for (int i = 0; i < n; i++) {
if (k & 1 << i) {
x = min(x, dp[k ^ 1 << i][j] + t[i]);
}
}
dp[k][j] = x;
}
}
for (int j = 0; j <= n; j++) {
if (dp[(1 << n) - 1][j] == 0) {
cout << j << endl;
break;
}
}
return 0;
}
merom686