結果

問題 No.937 Ultra Sword
ユーザー kotatsugamekotatsugame
提出日時 2019-11-29 22:39:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 861 bytes
コンパイル時間 638 ms
コンパイル使用メモリ 67,868 KB
実行使用メモリ 14,016 KB
最終ジャッジ日時 2024-05-01 02:41:20
合計ジャッジ時間 5,380 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
13,756 KB
testcase_01 AC 11 ms
6,940 KB
testcase_02 AC 15 ms
6,944 KB
testcase_03 AC 15 ms
6,944 KB
testcase_04 AC 16 ms
6,944 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
int N,A[1<<17];
long S[1<<17];
long sum=0,ans=0;
long B[1700000];
bool dp[1<<17];
main()
{
	cin>>N;
	int sz=0;
	for(int i=0;i<N;i++)
	{
		long a;cin>>a;A[a]++;
		sum+=a;
		for(int j=0;j<17;j++)
		{
			B[i*17+j]=a<<j;
		}
	}
	for(int i=100000;i>0;i--)
	{
		int c=0;
		for(int j=i;j<=100000;j+=i)
		{
			S[i]+=A[j]*(long)(j/i*(i-1));
		}
	}
	for(int i=0;i<44;i++)
	{
		int id=-1;
		for(int j=i;j<17*N;j++)
		{
			if(B[j]>>i&1)
			{
				id=j;
				break;
			}
		}
		if(id<0)break;
		if(id!=i)
		{
			swap(B[id],B[i]);
		}
		for(int j=0;j<17*N;j++)
		{
			if(i!=j&&B[j]>>i&1)B[j]^=B[i];
		}
	}
	dp[0]=true;
	for(int i=0;i<17*N;i++)
	{
		if(!(B[i]>>17))
		{
			for(int k=0;k<1<<17;k++)
			{
				if(dp[k])dp[k^B[i]]=true;
			}
		}
	}
	for(int i=0;i<1<<17;i++)if(dp[i])ans=max(ans,S[i]);
	cout<<sum-ans<<endl;
}
0