結果

問題 No.937 Ultra Sword
ユーザー face4face4
提出日時 2019-11-29 23:02:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,109 bytes
コンパイル時間 774 ms
コンパイル使用メモリ 71,364 KB
実行使用メモリ 4,416 KB
最終ジャッジ日時 2023-08-13 09:10:21
合計ジャッジ時間 8,146 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 377 ms
4,384 KB
testcase_06 AC 215 ms
4,384 KB
testcase_07 AC 238 ms
4,380 KB
testcase_08 AC 107 ms
4,416 KB
testcase_09 AC 82 ms
4,384 KB
testcase_10 AC 261 ms
4,384 KB
testcase_11 AC 21 ms
4,384 KB
testcase_12 AC 97 ms
4,380 KB
testcase_13 AC 94 ms
4,380 KB
testcase_14 AC 107 ms
4,380 KB
testcase_15 AC 81 ms
4,380 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 10 ms
4,380 KB
testcase_18 AC 88 ms
4,384 KB
testcase_19 AC 52 ms
4,384 KB
testcase_20 AC 46 ms
4,380 KB
testcase_21 AC 273 ms
4,384 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 340 ms
4,380 KB
testcase_25 AC 238 ms
4,384 KB
testcase_26 AC 196 ms
4,380 KB
testcase_27 AC 193 ms
4,380 KB
testcase_28 AC 214 ms
4,384 KB
testcase_29 AC 8 ms
4,380 KB
testcase_30 AC 158 ms
4,380 KB
testcase_31 AC 263 ms
4,380 KB
testcase_32 AC 152 ms
4,380 KB
testcase_33 AC 264 ms
4,384 KB
testcase_34 AC 41 ms
4,384 KB
testcase_35 AC 19 ms
4,380 KB
testcase_36 AC 222 ms
4,380 KB
testcase_37 AC 20 ms
4,384 KB
testcase_38 AC 174 ms
4,384 KB
testcase_39 AC 10 ms
4,380 KB
testcase_40 AC 208 ms
4,380 KB
testcase_41 AC 77 ms
4,380 KB
testcase_42 AC 161 ms
4,380 KB
testcase_43 AC 146 ms
4,384 KB
testcase_44 AC 50 ms
4,384 KB
testcase_45 AC 93 ms
4,384 KB
testcase_46 AC 96 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    
    vector<int> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];

    ll ans = accumulate(v.begin(), v.end(), 0ll);

    vector<ll> d(100001);
    for(int i = 0; i < n; i++){
        ll x = v[i];
        for(ll i = 1; i*i <= x; i++){
            if(x%i) continue;
            d[i] += x-x/i;
            if(i*i != x)    d[x/i] += x-i;
        }
    }

    // 掃き出し
    int rank = 0;
    for(int i = 17; i >= 0; i--){
        int j;
        for(j = rank; j < n; j++){
            if((v[j]>>i)&1) break;
        }
        if(j == n)  continue;
        swap(v[rank], v[j]);
        for(j = 0; j < n; j++){
            if(j == rank)   continue;
            if((v[j]>>i)&1) v[j] ^= v[rank];
        }
        rank++;
    }
    ll sub = 0;
    for(int i = 1; i < 1<<rank; i++){
        int xo = 0;
        for(int j = 0; j < rank; j++)   if((i>>j)&1)    xo ^= v[j];
        if(xo <= 100000)    sub = max(sub, d[xo]);
    }
    cout << ans-sub << endl;
    return 0;
}
0