結果

問題 No.2488 Mod Sum Maximization
ユーザー pockynypockyny
提出日時 2023-10-29 22:33:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 995 bytes
コンパイル時間 1,441 ms
コンパイル使用メモリ 97,904 KB
実行使用メモリ 38,100 KB
最終ジャッジ日時 2023-10-29 22:34:26
合計ジャッジ時間 34,501 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 959 ms
35,572 KB
testcase_01 AC 340 ms
35,572 KB
testcase_02 AC 17 ms
35,572 KB
testcase_03 AC 1,328 ms
37,948 KB
testcase_04 AC 1,320 ms
37,948 KB
testcase_05 AC 1,314 ms
37,948 KB
testcase_06 AC 1,257 ms
37,684 KB
testcase_07 AC 932 ms
37,156 KB
testcase_08 AC 1,299 ms
37,948 KB
testcase_09 AC 966 ms
37,420 KB
testcase_10 AC 753 ms
36,892 KB
testcase_11 AC 54 ms
35,572 KB
testcase_12 AC 682 ms
36,628 KB
testcase_13 AC 556 ms
36,628 KB
testcase_14 AC 146 ms
35,836 KB
testcase_15 AC 835 ms
36,892 KB
testcase_16 AC 64 ms
35,572 KB
testcase_17 AC 269 ms
36,100 KB
testcase_18 AC 93 ms
35,836 KB
testcase_19 AC 1,081 ms
37,420 KB
testcase_20 AC 1,172 ms
37,684 KB
testcase_21 AC 1,127 ms
37,684 KB
testcase_22 AC 1,273 ms
37,948 KB
testcase_23 AC 1,310 ms
37,948 KB
testcase_24 AC 496 ms
36,364 KB
testcase_25 AC 45 ms
35,572 KB
testcase_26 AC 86 ms
35,572 KB
testcase_27 AC 1,352 ms
36,892 KB
testcase_28 AC 1,459 ms
36,892 KB
testcase_29 AC 1,101 ms
36,628 KB
testcase_30 AC 883 ms
36,364 KB
testcase_31 AC 151 ms
35,836 KB
testcase_32 TLE -
testcase_33 AC 27 ms
35,572 KB
testcase_34 TLE -
testcase_35 AC 645 ms
36,364 KB
testcase_36 AC 18 ms
35,572 KB
testcase_37 AC 19 ms
35,572 KB
testcase_38 AC 19 ms
35,572 KB
testcase_39 AC 18 ms
35,572 KB
testcase_40 AC 18 ms
35,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <atcoder/lazysegtree>

using namespace std;
using namespace atcoder;
typedef long long ll;

//range chmin range min
ll inf = 1000000000000000000;
struct S{ll x;};
struct F{ll x;};
S op(S l,S r){return S{min(l.x,r.x)};}
S e(){return S{inf};}
S mapping(F l,S r){return S{min(l.x,r.x)};}
F compo(F l,F r){return F{min(l.x,r.x)};}
F id(){return F{inf};}

ll a[300010];
int main(){
    int i,j,n; cin >> n;
    for(i=0;i<n;i++) cin >> a[i];
    const int mx = 1000000;
    vector<S> v(mx + 1);
    for(i=0;i<=mx;i++) v[i] = e(); 
    lazy_segtree<S,op,e,F,mapping,compo,id> seg(v);
    ll ans = 0;
    for(i=0;i<n;i++) ans += a[i];
    seg.set(a[0],S{0});
    for(i=0;i<n;i++){
        // cout << i << endl;
        ll x = a[i];
        ll c = a[i];
        for(j=x;j<=mx;j+=x){
            // cout << j << endl;
            seg.apply(j,min((ll)mx + 1,j + x),F{seg.get(a[i]).x + c});
            c += a[i];
        }
    }
    cout << ans - seg.get(a[n - 1]).x << endl;
}
0