結果

問題 No.2330 Eat Slime
ユーザー shobonvipshobonvip
提出日時 2023-05-28 15:04:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,003 ms / 4,000 ms
コード長 837 bytes
コンパイル時間 4,385 ms
コンパイル使用メモリ 263,048 KB
実行使用メモリ 37,912 KB
最終ジャッジ日時 2023-08-27 11:20:15
合計ジャッジ時間 27,222 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 913 ms
31,780 KB
testcase_08 AC 455 ms
24,936 KB
testcase_09 AC 905 ms
25,596 KB
testcase_10 AC 139 ms
7,284 KB
testcase_11 AC 108 ms
4,468 KB
testcase_12 AC 912 ms
29,292 KB
testcase_13 AC 881 ms
31,252 KB
testcase_14 AC 202 ms
6,412 KB
testcase_15 AC 530 ms
24,412 KB
testcase_16 AC 870 ms
26,072 KB
testcase_17 AC 993 ms
37,648 KB
testcase_18 AC 993 ms
37,504 KB
testcase_19 AC 996 ms
37,520 KB
testcase_20 AC 996 ms
37,644 KB
testcase_21 AC 994 ms
37,516 KB
testcase_22 AC 999 ms
37,724 KB
testcase_23 AC 999 ms
37,604 KB
testcase_24 AC 989 ms
37,648 KB
testcase_25 AC 996 ms
37,912 KB
testcase_26 AC 990 ms
37,772 KB
testcase_27 AC 1,003 ms
37,792 KB
testcase_28 AC 994 ms
37,564 KB
testcase_29 AC 1,000 ms
37,412 KB
testcase_30 AC 996 ms
37,720 KB
testcase_31 AC 992 ms
37,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef modint998244353 mint;
typedef long long ll;

int main(){
	int n, m, x; cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<ll>> lst(5, vector<ll>(n));
	for (int i=0; i<n; i++){
		cin >> c[i];
		c[i]--;
		lst[c[i]][i] += 1;
	}

	vector<vector<ll>> bonus(5, vector<ll>(n));
	for (int i=0; i<m; i++){
		int a, b, y; cin >> a >> b >> y;
		a--; b--;
		bonus[b][a] += y;
	}
	for (int i=0; i<5; i++){
		reverse(lst[i].begin(), lst[i].end());
	}
	ll ans = n * x;
	vector<ll> qr(n);
	for (int i=0; i<n; i++){
		qr[i] = i * x;
	}
	for (int j=0; j<5; j++){
		vector<ll> ar = convolution_ll(lst[j], bonus[j]);
		for (int i=0; i<n; i++){
			qr[i] += ar[n-1-i];
		}
	}
	for (int i=0; i<n; i++){
		ans = max(ans, qr[i]);
	}
	cout << ans << endl;
}

0