結果

問題 No.2941 Sigma Music Game Score Problem
ユーザー otoshigootoshigo
提出日時 2024-10-18 22:01:25
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 293 ms / 2,500 ms
コード長 728 bytes
コンパイル時間 2,388 ms
コンパイル使用メモリ 204,880 KB
実行使用メモリ 11,012 KB
最終ジャッジ日時 2024-10-18 22:44:34
合計ジャッジ時間 6,804 ms
ジャッジサーバーID
(参考情報)
judge4 / judge
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace std;
using ll=long long;
using mint=atcoder::modint998244353;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll M,N;
    cin>>M>>N;
    vector<ll>X(N+2);
    for(int i=1;i<=N;i++)cin>>X[i];
    X[N+1]=M+1;
    mint ans=0;
    for(int i=1;i<=N+1;i++){
        if(X[i-1]+1==X[i])continue;
        ll l=X[i]-X[i-1]-1;
        ans+=(mint)l*(l+1)*(2*l+1)/6;
    }
    cout<<ans.val()<<"\n";
}
0