結果

問題 No.2941 Sigma Music Game Score Problem
ユーザー 沙耶花
提出日時 2024-10-18 21:50:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 881 ms / 2,500 ms
コード長 598 bytes
コンパイル時間 4,083 ms
コンパイル使用メモリ 253,296 KB
最終ジャッジ日時 2025-02-24 20:40:05
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000000LL

mint f2(long long n){
	mint ret = n;
	ret *= n+1;
	ret *= n*2+1;
	ret /= 6;
	return ret;
}

int main(){
	
	long long n,m;
	cin>>n>>m;
	vector<long long> a(m);
	rep(i,m)cin>>a[i];
	a.push_back(0);
	a.push_back(n+1);
	sort(a.begin(),a.end());
	mint ans = 0;
	rep(i,a.size()-1){
		ans += f2(a[i+1]-a[i]-1);
	}
	cout<<ans.val()<<endl;
	
	return 0;
}
0