結果

問題 No.733 分身並列コーディング
ユーザー polylogKpolylogK
提出日時 2018-09-07 23:39:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 308 ms / 1,500 ms
コード長 717 bytes
コンパイル時間 1,864 ms
コンパイル使用メモリ 168,676 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-20 01:31:26
合計ジャッジ時間 9,312 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,388 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 166 ms
4,384 KB
testcase_04 AC 164 ms
4,380 KB
testcase_05 AC 283 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 278 ms
4,380 KB
testcase_08 AC 284 ms
4,384 KB
testcase_09 AC 68 ms
4,380 KB
testcase_10 AC 5 ms
4,384 KB
testcase_11 AC 5 ms
4,384 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 23 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,384 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 66 ms
4,380 KB
testcase_20 AC 78 ms
4,384 KB
testcase_21 AC 25 ms
4,384 KB
testcase_22 AC 197 ms
4,380 KB
testcase_23 AC 26 ms
4,384 KB
testcase_24 AC 30 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,384 KB
testcase_27 AC 3 ms
4,380 KB
testcase_28 AC 294 ms
4,380 KB
testcase_29 AC 252 ms
4,384 KB
testcase_30 AC 248 ms
4,384 KB
testcase_31 AC 260 ms
4,380 KB
testcase_32 AC 15 ms
4,380 KB
testcase_33 AC 13 ms
4,384 KB
testcase_34 AC 13 ms
4,380 KB
testcase_35 AC 15 ms
4,384 KB
testcase_36 AC 13 ms
4,380 KB
testcase_37 AC 13 ms
4,384 KB
testcase_38 AC 272 ms
4,384 KB
testcase_39 AC 283 ms
4,380 KB
testcase_40 AC 283 ms
4,384 KB
testcase_41 AC 14 ms
4,384 KB
testcase_42 AC 13 ms
4,380 KB
testcase_43 AC 12 ms
4,380 KB
testcase_44 AC 286 ms
4,380 KB
testcase_45 AC 287 ms
4,384 KB
testcase_46 AC 284 ms
4,380 KB
testcase_47 AC 308 ms
4,380 KB
testcase_48 AC 290 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int T, n; cin >> T >> n; std::vector<int> t(n);
	for(int i = 0; i < n; i++) cin >> t[i];
	
	std::vector<int> vec;
	std::vector<bool> li(1 << n, false);
	for(int i = 1; i < (1 << n); i++) {
		int tmp = 0;
		for(int j = 0; j < n; j++) if((i >> j) & 1) tmp += t[j];
		
		if(tmp > T) continue;
		li[i] = true;
	}
	
	std::vector<int> dp(1 << n, 1 << 30); dp[0] = 0;
	for(int i = 0; i < (1 << n); i++) {
		for(int bit = ~i & ((1 << n) - 1); bit >= 0; bit--) {
			bit &= ~i & ((1 << n) - 1);
			if(li[bit]) dp[i | bit] = std::min(dp[i | bit], dp[i] + 1);
		}
	}
	
	cout << dp[(1 << n) - 1] << endl;
	return 0;
}
0