結果

問題 No.733 分身並列コーディング
ユーザー kotatsugame
提出日時 2020-02-12 00:19:52
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 179 ms / 1,500 ms
コード長 485 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 65,984 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-01 13:05:13
合計ジャッジ時間 4,888 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます
コンパイルメッセージ
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