結果
| 問題 |
No.2941 Sigma Music Game Score Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-07 00:20:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 723 ms / 2,500 ms |
| コード長 | 968 bytes |
| コンパイル時間 | 683 ms |
| コンパイル使用メモリ | 71,272 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-01-07 00:20:55 |
| 合計ジャッジ時間 | 10,925 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 |
ソースコード
#include <stdio.h>
#include <iostream>//cin/cout
#include <string>//cout string
#include <algorithm>
#include <cmath>
#include <atcoder/modint.hpp>
using namespace atcoder;//modint
using namespace std;
using llong = long long;
const llong INF = 1LL << 60;
//const int INF = 1LL << 30;
using mint = modint998244353;
///////////////////ここまでtoolbox/////////////////////////////////////
//★2で問題文が平易だったので初参加
//提出システムがatcoderlibを使えるのかがわからなくて他人の提出を覗いたりした
int main() {
llong M, N;
cin >> M >> N;
mint i = 0;
mint ans = 0;
for (int n = 0; n < N; n++) {
llong X;
cin >> X;
//X-1 - iコンボ
mint Si = (X - 1LL) - i;
ans += Si * (Si + 1LL) * (Si * 2LL + 1LL) / 6LL;//わからんくて検索したべた...
i = X;
}
mint Si = M - i;//ゴールまでのコンボ
ans += Si * (Si + 1LL) * (Si * 2LL + 1LL) / 6LL;
cout << ans.val() << endl;
return 0;
}