結果

問題 No.733 分身並列コーディング
ユーザー kotatsugamekotatsugame
提出日時 2020-02-12 00:19:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 192 ms / 1,500 ms
コード長 485 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 65,084 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-04-08 22:07:27
合計ジャッジ時間 5,113 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 109 ms
6,548 KB
testcase_04 AC 110 ms
6,548 KB
testcase_05 AC 161 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 161 ms
6,548 KB
testcase_08 AC 161 ms
6,548 KB
testcase_09 AC 45 ms
6,548 KB
testcase_10 AC 4 ms
6,548 KB
testcase_11 AC 3 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 16 ms
6,548 KB
testcase_15 AC 2 ms
6,548 KB
testcase_16 AC 2 ms
6,548 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 5 ms
6,548 KB
testcase_19 AC 42 ms
6,548 KB
testcase_20 AC 48 ms
6,548 KB
testcase_21 AC 17 ms
6,548 KB
testcase_22 AC 117 ms
6,548 KB
testcase_23 AC 17 ms
6,548 KB
testcase_24 AC 18 ms
6,548 KB
testcase_25 AC 2 ms
6,548 KB
testcase_26 AC 2 ms
6,548 KB
testcase_27 AC 3 ms
6,548 KB
testcase_28 AC 180 ms
6,548 KB
testcase_29 AC 156 ms
6,548 KB
testcase_30 AC 151 ms
6,548 KB
testcase_31 AC 154 ms
6,548 KB
testcase_32 AC 10 ms
6,548 KB
testcase_33 AC 9 ms
6,548 KB
testcase_34 AC 9 ms
6,548 KB
testcase_35 AC 10 ms
6,548 KB
testcase_36 AC 9 ms
6,548 KB
testcase_37 AC 9 ms
6,548 KB
testcase_38 AC 178 ms
6,548 KB
testcase_39 AC 190 ms
6,548 KB
testcase_40 AC 166 ms
6,548 KB
testcase_41 AC 9 ms
6,548 KB
testcase_42 AC 8 ms
6,548 KB
testcase_43 AC 9 ms
6,548 KB
testcase_44 AC 174 ms
6,548 KB
testcase_45 AC 192 ms
6,548 KB
testcase_46 AC 188 ms
6,548 KB
testcase_47 AC 180 ms
6,548 KB
testcase_48 AC 176 ms
6,548 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int T,N,t[17],s[1<<17];
int ok[1<<17];
main()
{
	cin>>T>>N;
	for(int i=0;i<N;i++)cin>>t[i];
	for(int i=0;i<1<<N;i++)
	{
		ok[i]=114514;
		for(int j=0;j<N;j++)if(i>>j&1)s[i]+=t[j];
	}
	ok[0]=0;
	for(int i=0;i<1<<N;i++)
	{
		int out=(1<<N)-1&~i;
		if(out==0)continue;
		int t=out&-out;
		out-=t;
		for(int k=out;;k=k-1&out)
		{
			if(s[k|t]<=T)
			{
				ok[i|k|t]=min(ok[i|k|t],ok[i]+1);
			}
			if(k==0)break;
		}
	}
	cout<<ok[(1<<N)-1]<<endl;
}
0