結果

問題 No.2880 Max Sigma Mod
ユーザー HIcoderHIcoder
提出日時 2024-09-09 23:51:33
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 3,000 ms
コード長 811 bytes
コンパイル時間 1,242 ms
コンパイル使用メモリ 120,156 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-09 23:51:37
合計ジャッジ時間 2,899 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<cassert>
#include<random>
#include<set>
#include<map>
#include<cassert>
#include<unordered_map>
#include<bitset>
#include<numeric>
#include<algorithm>
using namespace std;
using ll = long long;
const int inf=1<<30;
const ll INF=1LL<<62;
typedef pair<int,ll> P;
typedef pair<int,P> PP; 
const ll MOD=998244353;
const int dy[]={0,1,0,-1};
const int dx[]={1,0,-1,0};

int main(){
    ll N,M;
    cin>>N>>M;
    
    vector<ll> S(N+1);
    vector<ll> plus(N+1,M);
    S[0]=0;

    for(int i=1;i<=M;i++){
        for(int j=i;j<=N;j+=i){
            plus[j]-=i;
        }
    }

    for(int i=1;i<=N;i++){
        S[i]=S[i-1]+plus[i];
    }
    ll ans=0;
    for(int i=1;i<=N;i++){
        ans=max(ans,S[i]);
    }

    cout<<ans<<endl;
}
0