結果

問題 No.2488 Mod Sum Maximization
ユーザー i_am_noobi_am_noob
提出日時 2023-10-29 18:47:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 661 bytes
コンパイル時間 2,095 ms
コンパイル使用メモリ 201,824 KB
実行使用メモリ 12,428 KB
最終ジャッジ日時 2023-10-29 18:47:31
合計ジャッジ時間 7,555 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
11,756 KB
testcase_01 AC 5 ms
11,756 KB
testcase_02 AC 5 ms
11,796 KB
testcase_03 AC 44 ms
12,428 KB
testcase_04 AC 43 ms
12,428 KB
testcase_05 AC 43 ms
12,428 KB
testcase_06 AC 41 ms
12,428 KB
testcase_07 AC 31 ms
12,428 KB
testcase_08 AC 43 ms
12,428 KB
testcase_09 AC 34 ms
12,428 KB
testcase_10 AC 26 ms
12,428 KB
testcase_11 AC 6 ms
12,428 KB
testcase_12 AC 25 ms
12,428 KB
testcase_13 AC 21 ms
12,428 KB
testcase_14 AC 9 ms
12,428 KB
testcase_15 AC 28 ms
12,428 KB
testcase_16 AC 6 ms
12,428 KB
testcase_17 AC 13 ms
12,428 KB
testcase_18 AC 8 ms
12,428 KB
testcase_19 AC 36 ms
12,428 KB
testcase_20 AC 39 ms
12,428 KB
testcase_21 AC 38 ms
12,428 KB
testcase_22 AC 42 ms
12,428 KB
testcase_23 AC 43 ms
12,428 KB
testcase_24 AC 19 ms
12,428 KB
testcase_25 AC 6 ms
12,428 KB
testcase_26 AC 7 ms
12,428 KB
testcase_27 AC 27 ms
12,428 KB
testcase_28 AC 27 ms
12,428 KB
testcase_29 AC 26 ms
12,428 KB
testcase_30 AC 19 ms
12,428 KB
testcase_31 AC 8 ms
12,428 KB
testcase_32 AC 38 ms
12,428 KB
testcase_33 AC 6 ms
12,416 KB
testcase_34 AC 45 ms
12,428 KB
testcase_35 AC 18 ms
12,428 KB
testcase_36 AC 4 ms
11,764 KB
testcase_37 AC 5 ms
11,916 KB
testcase_38 AC 5 ms
11,920 KB
testcase_39 AC 4 ms
11,836 KB
testcase_40 AC 4 ms
11,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;

#define all(a) a.begin(),a.end()
#define pb push_back
#define sz(a) ((int)a.size())

const int N=1000005;

int n,a[N],t[N];
bool vis[N];

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    for(int i=0; i<n; ++i) cin >> a[i],vis[a[i]]=1;
    memset(t,-1,sizeof t);
    int cur=0;
    for(int i=0; i<N; ++i) if(vis[i]){
        if(i>a[0]){
            while(t[cur]<i) cur++;
        }
        for(int j=2; cur+(j-1)*i<N; ++j){
            t[cur+(j-1)*i]=max(t[cur+(j-1)*i],i*j-1);
        }
    }
    cout << accumulate(a,a+n,0ll)-cur << "\n";
}
0