結果

問題 No.2941 Sigma Music Game Score Problem
コンテスト
ユーザー a1048576
提出日時 2024-10-18 22:35:31
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 391 ms / 2,500 ms
コード長 431 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,842 ms
コンパイル使用メモリ 249,920 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2026-05-05 15:51:07
合計ジャッジ時間 11,318 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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