結果

問題 No.2330 Eat Slime
ユーザー m_99
提出日時 2023-05-28 14:31:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,004 ms / 4,000 ms
コード長 787 bytes
コンパイル時間 4,054 ms
コンパイル使用メモリ 253,296 KB
最終ジャッジ日時 2025-02-13 11:38:59
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

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 4000000000000000001


int main(){
	
	int N,M,X;
	cin>>N>>M>>X;
	
	vector<vector<long long>> c(5,vector<long long>(N));
	rep(j,N){
		int t;
		cin>>t;
		c[t-1][j] = 1;
	}
	
	vector<vector<long long>> t(5,vector<long long>(N));
	rep(i,M){
		int x,y,z;
		cin>>x>>y>>z;
		x--,y--;
		t[y][N-1-x] += z;
	}
	vector<long long> ans(N);
	rep(i,5){
		auto tt=  convolution_ll(c[i],t[i]);
		rep(j,N){
			ans[j] += tt[N-1+j];
		}
	}
	rep(i,N)ans[i] += X * i;
	
	long long aa = 0;
	rep(i,N)aa = max(aa,ans[i]);
	aa = max(aa,(long long)N*X);
	cout<<aa<<endl;
	
	return 0;
}
0