結果

問題 No.2941 Sigma Music Game Score Problem
ユーザー a1048576
提出日時 2024-10-18 22:35:31
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 595 ms / 2,500 ms
コード長 431 bytes
コンパイル時間 3,880 ms
コンパイル使用メモリ 229,752 KB
実行使用メモリ 11,116 KB
最終ジャッジ日時 2024-10-18 22:52:45
合計ジャッジ時間 10,723 ms
ジャッジサーバーID
(参考情報)
judge5 / judge7
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all> 
using mint = atcoder::modint998244353;
#define int long long
signed main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(m+2);
  a[0] = 0;
  for(int i = 1; i <= m; i++) cin >> a[i];
  a[m+1] = n+1;
  mint ans = 0, mod = 998244353;
  for(int i = 0; i < m+1; i++) {
    mint s = a[i+1]-a[i]-1;
    ans+=s*(s+1)*(s*2+1);
  }
  ans/=6;
  cout << ans.val() << endl;
}
0