結果

問題 No.2941 Sigma Music Game Score Problem
ユーザー Tatsu_mr
提出日時 2025-03-03 14:20:30
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 295 ms / 2,500 ms
コード長 940 bytes
コンパイル時間 3,221 ms
コンパイル使用メモリ 278,296 KB
実行使用メモリ 11,096 KB
最終ジャッジ日時 2025-03-03 14:20:40
合計ジャッジ時間 8,571 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) For(i, 0, n)
#define rFor(i, a, b) for(int i = (a); i >= (b); i--)
#define ALL(v) (v).begin(), (v).end()
#define rALL(v) (v).rbegin(), (v).rend()

using lint = long long;
using ld = long double;

int INF = 2000000000;
lint LINF = 1000000000000000000;

struct SetupIo {
    SetupIo() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        cout << fixed << setprecision(15);
    }
} setupio;

#include <atcoder/modint>
using mint = atcoder::modint998244353;

int main() {
    lint m, n;
    cin >> m >> n;
    vector<lint> x(n + 2);
    x[0] = 0;
    x[n + 1] = m + 1;
    For(i, 1, n + 1) {
        cin >> x[i];
    }
    mint ans = 0;
    rep(i, n + 1) {
        lint cnt = x[i + 1] - x[i] - 1;
        ans += mint(cnt) * mint(cnt + 1) * mint(2 * cnt + 1) / mint(6);
    }
    cout << ans.val() << "\n";
}
0