結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 50 ms
6,944 KB
testcase_06 AC 79 ms
6,944 KB
testcase_07 AC 87 ms
6,944 KB
testcase_08 AC 39 ms
6,944 KB
testcase_09 AC 32 ms
6,940 KB
testcase_10 AC 96 ms
6,940 KB
testcase_11 AC 14 ms
6,940 KB
testcase_12 AC 66 ms
6,940 KB
testcase_13 AC 67 ms
6,940 KB
testcase_14 AC 75 ms
6,940 KB
testcase_15 AC 54 ms
6,940 KB
testcase_16 AC 3 ms
6,948 KB
testcase_17 AC 6 ms
6,940 KB
testcase_18 AC 61 ms
6,944 KB
testcase_19 AC 36 ms
6,940 KB
testcase_20 AC 31 ms
6,944 KB
testcase_21 AC 95 ms
6,944 KB
testcase_22 WA -
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 53 ms
6,944 KB
testcase_25 AC 52 ms
6,940 KB
testcase_26 WA -
testcase_27 AC 44 ms
6,944 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 40 ms
6,940 KB
testcase_31 AC 59 ms
6,944 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 7 ms
6,940 KB
testcase_36 AC 52 ms
6,940 KB
testcase_37 WA -
testcase_38 AC 41 ms
6,944 KB
testcase_39 AC 5 ms
6,940 KB
testcase_40 AC 45 ms
6,940 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 17 ms
6,940 KB
testcase_45 WA -
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;
int A[112345], cnt[112345];

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