結果

問題 No.2330 Eat Slime
ユーザー kotatsugamekotatsugame
提出日時 2023-05-28 14:18:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 345 ms / 4,000 ms
コード長 767 bytes
コンパイル時間 2,226 ms
コンパイル使用メモリ 111,652 KB
実行使用メモリ 14,980 KB
最終ジャッジ日時 2023-08-27 09:29:40
合計ジャッジ時間 11,038 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,504 KB
testcase_01 AC 2 ms
5,436 KB
testcase_02 AC 2 ms
5,484 KB
testcase_03 AC 2 ms
5,632 KB
testcase_04 AC 2 ms
5,488 KB
testcase_05 AC 2 ms
5,704 KB
testcase_06 AC 2 ms
5,456 KB
testcase_07 AC 289 ms
13,444 KB
testcase_08 AC 119 ms
10,352 KB
testcase_09 AC 303 ms
13,280 KB
testcase_10 AC 65 ms
6,632 KB
testcase_11 AC 78 ms
6,172 KB
testcase_12 AC 295 ms
13,280 KB
testcase_13 AC 264 ms
13,140 KB
testcase_14 AC 136 ms
7,088 KB
testcase_15 AC 191 ms
10,788 KB
testcase_16 AC 267 ms
13,036 KB
testcase_17 AC 342 ms
14,840 KB
testcase_18 AC 343 ms
14,720 KB
testcase_19 AC 341 ms
14,804 KB
testcase_20 AC 343 ms
14,848 KB
testcase_21 AC 344 ms
14,752 KB
testcase_22 AC 336 ms
14,672 KB
testcase_23 AC 344 ms
14,712 KB
testcase_24 AC 343 ms
14,688 KB
testcase_25 AC 345 ms
14,644 KB
testcase_26 AC 344 ms
14,664 KB
testcase_27 AC 342 ms
14,716 KB
testcase_28 AC 337 ms
14,644 KB
testcase_29 AC 344 ms
14,844 KB
testcase_30 AC 344 ms
14,980 KB
testcase_31 AC 343 ms
14,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<atcoder/modint>
#include<atcoder/convolution>
using namespace std;
using mint=atcoder::modint998244353;
int N,M,X;
int C[2<<17];
int A[2<<17],B[2<<17],Y[2<<17];
int ans[2<<17];
int main()
{
	cin>>N>>M>>X;
	for(int i=0;i<N;i++)cin>>C[i];
	for(int i=0;i<M;i++)cin>>A[i]>>B[i]>>Y[i];
	for(int col=1;col<=5;col++)
	{
		vector<mint>idx(N,mint::raw(0));
		for(int i=0;i<N;i++)if(C[i]==col)idx[i]=mint::raw(1);
		vector<mint>coef(N,mint::raw(0));
		for(int i=0;i<M;i++)if(B[i]==col)
		{
			coef[N-A[i]]+=mint::raw(Y[i]);
		}
		vector<mint>t=atcoder::convolution(idx,coef);
		for(int i=N-1;i<2*N-1;i++)ans[i-(N-1)]+=t[i].val();
	}
	int ret=0;
	for(int i=0;i<=N;i++)ret=max(ret,ans[i]+i*X);
	cout<<ret<<endl;
}
0