結果
問題 | No.2488 Mod Sum Maximization |
ユーザー |
|
提出日時 | 2023-10-29 18:47:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 661 bytes |
コンパイル時間 | 1,748 ms |
コンパイル使用メモリ | 192,044 KB |
最終ジャッジ日時 | 2025-02-17 16:52:02 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#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"; }