結果
問題 | No.2941 Sigma Music Game Score Problem |
ユーザー |
|
提出日時 | 2024-10-18 22:01:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 294 ms / 2,500 ms |
コード長 | 728 bytes |
コンパイル時間 | 2,199 ms |
コンパイル使用メモリ | 196,272 KB |
最終ジャッジ日時 | 2025-02-24 20:45:20 |
ジャッジサーバーID (参考情報) |
judge1 / judge |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
ソースコード
#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";}