結果

問題 No.937 Ultra Sword
ユーザー tkmst201tkmst201
提出日時 2019-11-29 23:17:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,414 bytes
コンパイル時間 1,894 ms
コンパイル使用メモリ 171,940 KB
実行使用メモリ 5,820 KB
最終ジャッジ日時 2023-08-13 09:13:20
合計ジャッジ時間 5,186 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 49 ms
4,736 KB
testcase_06 AC 76 ms
5,372 KB
testcase_07 AC 83 ms
5,804 KB
testcase_08 AC 42 ms
4,940 KB
testcase_09 AC 36 ms
5,052 KB
testcase_10 AC 92 ms
5,756 KB
testcase_11 AC 13 ms
4,384 KB
testcase_12 AC 56 ms
4,628 KB
testcase_13 AC 58 ms
4,380 KB
testcase_14 AC 65 ms
4,580 KB
testcase_15 AC 46 ms
4,380 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 7 ms
4,380 KB
testcase_18 AC 53 ms
4,476 KB
testcase_19 AC 32 ms
4,380 KB
testcase_20 AC 28 ms
4,376 KB
testcase_21 AC 87 ms
5,696 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,384 KB
testcase_24 AC 49 ms
4,756 KB
testcase_25 AC 46 ms
5,820 KB
testcase_26 AC 40 ms
5,432 KB
testcase_27 AC 39 ms
5,492 KB
testcase_28 AC 47 ms
5,420 KB
testcase_29 AC 3 ms
4,516 KB
testcase_30 AC 34 ms
5,148 KB
testcase_31 AC 51 ms
5,756 KB
testcase_32 AC 30 ms
5,276 KB
testcase_33 AC 51 ms
5,816 KB
testcase_34 AC 11 ms
4,900 KB
testcase_35 AC 6 ms
4,632 KB
testcase_36 AC 46 ms
5,476 KB
testcase_37 AC 6 ms
4,700 KB
testcase_38 AC 36 ms
5,264 KB
testcase_39 AC 4 ms
4,584 KB
testcase_40 AC 40 ms
5,484 KB
testcase_41 AC 16 ms
4,760 KB
testcase_42 AC 31 ms
5,224 KB
testcase_43 AC 29 ms
5,112 KB
testcase_44 AC 13 ms
4,668 KB
testcase_45 AC 19 ms
4,896 KB
testcase_46 AC 24 ms
4,888 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