結果

問題 No.2488 Mod Sum Maximization
ユーザー pockynypockyny
提出日時 2023-10-29 22:35:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 987 bytes
コンパイル時間 1,007 ms
コンパイル使用メモリ 97,820 KB
実行使用メモリ 20,616 KB
最終ジャッジ日時 2023-10-29 22:36:00
合計ジャッジ時間 30,778 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 928 ms
19,560 KB
testcase_01 AC 355 ms
19,560 KB
testcase_02 AC 12 ms
19,560 KB
testcase_03 AC 1,202 ms
20,616 KB
testcase_04 AC 1,205 ms
20,616 KB
testcase_05 AC 1,172 ms
20,616 KB
testcase_06 AC 1,110 ms
20,616 KB
testcase_07 AC 815 ms
20,352 KB
testcase_08 AC 1,111 ms
20,616 KB
testcase_09 AC 846 ms
20,352 KB
testcase_10 AC 633 ms
20,088 KB
testcase_11 AC 43 ms
19,560 KB
testcase_12 AC 597 ms
20,088 KB
testcase_13 AC 488 ms
19,824 KB
testcase_14 AC 125 ms
19,560 KB
testcase_15 AC 736 ms
20,088 KB
testcase_16 AC 50 ms
19,560 KB
testcase_17 AC 231 ms
19,560 KB
testcase_18 AC 77 ms
19,560 KB
testcase_19 AC 966 ms
20,352 KB
testcase_20 AC 1,039 ms
20,616 KB
testcase_21 AC 988 ms
20,352 KB
testcase_22 AC 1,130 ms
20,616 KB
testcase_23 AC 1,166 ms
20,616 KB
testcase_24 AC 433 ms
19,824 KB
testcase_25 AC 35 ms
19,560 KB
testcase_26 AC 77 ms
19,560 KB
testcase_27 AC 1,206 ms
20,088 KB
testcase_28 AC 1,351 ms
20,088 KB
testcase_29 AC 954 ms
20,088 KB
testcase_30 AC 800 ms
19,824 KB
testcase_31 AC 127 ms
19,560 KB
testcase_32 TLE -
testcase_33 AC 19 ms
19,560 KB
testcase_34 AC 1,754 ms
20,616 KB
testcase_35 AC 569 ms
19,824 KB
testcase_36 AC 10 ms
19,560 KB
testcase_37 AC 9 ms
19,560 KB
testcase_38 AC 10 ms
19,560 KB
testcase_39 AC 9 ms
19,560 KB
testcase_40 AC 10 ms
19,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;
using namespace atcoder;
typedef int ll;

//range chmin range min
ll inf = 1000000000;
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);
    long long 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