結果

問題 No.937 Ultra Sword
ユーザー tkmst201tkmst201
提出日時 2019-11-29 23:13:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,404 bytes
コンパイル時間 1,894 ms
コンパイル使用メモリ 174,756 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 02:47:03
合計ジャッジ時間 4,669 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 39 ms
6,940 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 15 ms
6,944 KB
testcase_12 AC 58 ms
6,944 KB
testcase_13 AC 60 ms
6,940 KB
testcase_14 AC 67 ms
6,940 KB
testcase_15 AC 48 ms
6,940 KB
testcase_16 AC 4 ms
6,940 KB
testcase_17 AC 8 ms
6,940 KB
testcase_18 AC 55 ms
6,940 KB
testcase_19 AC 34 ms
6,944 KB
testcase_20 AC 29 ms
6,944 KB
testcase_21 WA -
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 39 ms
6,944 KB
testcase_25 AC 42 ms
6,944 KB
testcase_26 AC 39 ms
6,944 KB
testcase_27 AC 37 ms
6,940 KB
testcase_28 WA -
testcase_29 AC 4 ms
6,944 KB
testcase_30 WA -
testcase_31 AC 49 ms
6,944 KB
testcase_32 WA -
testcase_33 AC 46 ms
6,940 KB
testcase_34 WA -
testcase_35 AC 6 ms
6,940 KB
testcase_36 WA -
testcase_37 AC 6 ms
6,944 KB
testcase_38 AC 34 ms
6,944 KB
testcase_39 AC 4 ms
6,944 KB
testcase_40 AC 37 ms
6,940 KB
testcase_41 AC 16 ms
6,944 KB
testcase_42 AC 29 ms
6,944 KB
testcase_43 AC 29 ms
6,944 KB
testcase_44 AC 14 ms
6,940 KB
testcase_45 AC 19 ms
6,940 KB
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

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];
		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 += cnt[j] * j - j / i * cnt[j];
		}
		chmax(ansd, cur);
	}
	
	ll ans = accumulate(A, A + N, 0ll);
	ans -= ansd;
	
	cout << ans << endl;
	
	return 0;
}
0