結果
| 問題 | No.937 Ultra Sword | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-11-29 22:39:32 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 861 bytes | 
| コンパイル時間 | 652 ms | 
| コンパイル使用メモリ | 68,148 KB | 
| 実行使用メモリ | 31,420 KB | 
| 最終ジャッジ日時 | 2024-11-21 02:34:04 | 
| 合計ジャッジ時間 | 155,498 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 TLE * 37 | 
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main()
      | ^~~~
            
            ソースコード
#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;
}
            
            
            
        