結果

問題 No.937 Ultra Sword
ユーザー face4face4
提出日時 2019-11-29 23:02:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,109 bytes
コンパイル時間 669 ms
コンパイル使用メモリ 71,904 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 02:46:21
合計ジャッジ時間 7,158 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,940 KB
testcase_05 AC 336 ms
6,940 KB
testcase_06 AC 192 ms
6,944 KB
testcase_07 AC 227 ms
6,940 KB
testcase_08 AC 96 ms
6,940 KB
testcase_09 AC 76 ms
6,944 KB
testcase_10 AC 240 ms
6,940 KB
testcase_11 AC 19 ms
6,940 KB
testcase_12 AC 85 ms
6,940 KB
testcase_13 AC 86 ms
6,944 KB
testcase_14 AC 98 ms
6,940 KB
testcase_15 AC 71 ms
6,940 KB
testcase_16 AC 4 ms
6,940 KB
testcase_17 AC 9 ms
6,944 KB
testcase_18 AC 80 ms
6,940 KB
testcase_19 AC 48 ms
6,940 KB
testcase_20 AC 42 ms
6,944 KB
testcase_21 AC 239 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 310 ms
6,940 KB
testcase_25 AC 211 ms
6,944 KB
testcase_26 AC 174 ms
6,940 KB
testcase_27 AC 171 ms
6,940 KB
testcase_28 AC 192 ms
6,944 KB
testcase_29 AC 6 ms
6,944 KB
testcase_30 AC 143 ms
6,940 KB
testcase_31 AC 231 ms
6,940 KB
testcase_32 AC 135 ms
6,940 KB
testcase_33 AC 234 ms
6,940 KB
testcase_34 AC 36 ms
6,944 KB
testcase_35 AC 17 ms
6,944 KB
testcase_36 AC 197 ms
6,940 KB
testcase_37 AC 18 ms
6,940 KB
testcase_38 AC 151 ms
6,944 KB
testcase_39 AC 10 ms
6,944 KB
testcase_40 AC 184 ms
6,944 KB
testcase_41 AC 68 ms
6,940 KB
testcase_42 AC 140 ms
6,944 KB
testcase_43 AC 131 ms
6,944 KB
testcase_44 AC 42 ms
6,944 KB
testcase_45 AC 86 ms
6,940 KB
testcase_46 AC 94 ms
6,944 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