結果

問題 No.937 Ultra Sword
ユーザー kotatsugamekotatsugame
提出日時 2019-11-29 22:46:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 890 bytes
コンパイル時間 804 ms
コンパイル使用メモリ 68,704 KB
実行使用メモリ 17,916 KB
最終ジャッジ日時 2024-05-01 02:42:44
合計ジャッジ時間 7,329 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,816 KB
testcase_01 AC 9 ms
6,940 KB
testcase_02 WA -
testcase_03 AC 8 ms
6,940 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 214 ms
15,184 KB
testcase_07 AC 243 ms
16,240 KB
testcase_08 AC 108 ms
9,708 KB
testcase_09 AC 79 ms
8,788 KB
testcase_10 AC 271 ms
17,196 KB
testcase_11 AC 45 ms
7,200 KB
testcase_12 AC 209 ms
16,024 KB
testcase_13 AC 204 ms
16,968 KB
testcase_14 AC 229 ms
17,352 KB
testcase_15 AC 182 ms
14,152 KB
testcase_16 AC 11 ms
6,944 KB
testcase_17 AC 23 ms
6,940 KB
testcase_18 AC 204 ms
16,428 KB
testcase_19 AC 122 ms
12,596 KB
testcase_20 AC 94 ms
10,204 KB
testcase_21 AC 156 ms
17,916 KB
testcase_22 WA -
testcase_23 AC 9 ms
6,940 KB
testcase_24 AC 112 ms
17,688 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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>1;i--)
	{
		for(int j=i;j<=100000;j+=i)
		{
			S[i]+=A[j]*(long)(j/i*(i-1));
		}
	}
	int idx=0;
	for(int i=0;i<34;i++)
	{
		int id=-1;
		for(int j=idx;j<17*N;j++)
		{
			if(B[j]>>i&1)
			{
				id=j;
				break;
			}
		}
		if(id<0)continue;
		if(id!=idx)
		{
			swap(B[id],B[idx]);
		}
		for(int j=0;j<17*N;j++)
		{
			if(idx!=j&&B[j]>>i&1)B[j]^=B[idx];
		}
		idx++;
	}
	dp[0]=true;
	for(int i=0;i<17*N;i++)
	{
		if(B[i]&&!(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