結果

問題 No.937 Ultra Sword
ユーザー tkmst201tkmst201
提出日時 2019-11-29 23:17:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,414 bytes
コンパイル時間 1,663 ms
コンパイル使用メモリ 174,572 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 02:48:58
合計ジャッジ時間 4,573 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 49 ms
6,940 KB
testcase_06 AC 78 ms
6,940 KB
testcase_07 AC 81 ms
6,944 KB
testcase_08 AC 42 ms
6,940 KB
testcase_09 AC 36 ms
6,944 KB
testcase_10 AC 92 ms
6,944 KB
testcase_11 AC 13 ms
6,944 KB
testcase_12 AC 56 ms
6,940 KB
testcase_13 AC 60 ms
6,940 KB
testcase_14 AC 66 ms
6,940 KB
testcase_15 AC 47 ms
6,940 KB
testcase_16 AC 4 ms
6,940 KB
testcase_17 AC 7 ms
6,940 KB
testcase_18 AC 54 ms
6,944 KB
testcase_19 AC 32 ms
6,944 KB
testcase_20 AC 28 ms
6,944 KB
testcase_21 AC 86 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 49 ms
6,944 KB
testcase_25 AC 45 ms
6,944 KB
testcase_26 AC 40 ms
6,944 KB
testcase_27 AC 40 ms
6,940 KB
testcase_28 AC 48 ms
6,944 KB
testcase_29 AC 4 ms
6,940 KB
testcase_30 AC 35 ms
6,944 KB
testcase_31 AC 52 ms
6,944 KB
testcase_32 AC 31 ms
6,944 KB
testcase_33 AC 52 ms
6,940 KB
testcase_34 AC 10 ms
6,944 KB
testcase_35 AC 5 ms
6,940 KB
testcase_36 AC 46 ms
6,944 KB
testcase_37 AC 7 ms
6,940 KB
testcase_38 AC 37 ms
6,944 KB
testcase_39 AC 4 ms
6,944 KB
testcase_40 AC 40 ms
6,940 KB
testcase_41 AC 17 ms
6,944 KB
testcase_42 AC 30 ms
6,944 KB
testcase_43 AC 28 ms
6,940 KB
testcase_44 AC 13 ms
6,940 KB
testcase_45 AC 20 ms
6,944 KB
testcase_46 AC 23 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N;
ll A[112345], cnt[112345];
int f[112345];

int main() {
	cin >> N;
	REP(i, N) {
		scanf("%lld", A + i);
		++cnt[A[i]];
	}
	
	ll maxa = *max_element(A, A + N);
	
	vector<ll> v(N);
	REP(i, N) v[i] = A[i];
	
	vector<ll> elem;
	for (int k = 25; k >= 0; k--) {
		sort(ALL(v), greater<ll>());
		
		ll mx = v[0];
		if (mx >> k & 1 ^ 1) continue;
		elem.push_back(mx);
		REP(i, v.size()) if (v[i] >> k & 1) v[i] = v[i] ^ mx;
	}
	
	REP(s, 1 << elem.size()) {
		int cur = 0;
		REP(i, elem.size()) if (s >> i & 1) cur ^= elem[i];
		if (cur <= maxa) f[cur] = true;
	}
	
	ll ansd = 0;
	FOR(i, 1, maxa + 1) if (f[i]) {
		ll cur = 0;
		for (int j = i; j <= maxa; j += i) {
			cur += (j - j / i) * cnt[j];
		}
		chmax(ansd, cur);
	}
	
	ll ans = accumulate(A, A + N, 0ll);
	ans -= ansd;
	
	cout << ans << endl;
	
	return 0;
}
0