結果
問題 | No.2330 Eat Slime |
ユーザー |
|
提出日時 | 2023-04-13 21:30:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 227 ms / 4,000 ms |
コード長 | 1,097 bytes |
コンパイル時間 | 3,462 ms |
コンパイル使用メモリ | 259,928 KB |
最終ジャッジ日時 | 2025-02-12 05:52:14 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using namespace atcoder;int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int n, m; cin >> n >> m;int x; cin >> x;vector<int> c(n);for(int i = 0; i < n; i++){cin >> c[i]; c[i]--;}vector<int> a(m), b(m);vector<int> y(m);for(int i = 0; i < m; i++){cin >> a[i] >> b[i] >> y[i];a[i]--, b[i]--;}vector<int> res(n + 1);for(int i = 0; i <= n; i++){res[i] = x * i;}vector<vector<int>> q(5, vector<int>(n));for(int i = 0; i < m; i++){q[b[i]][a[i]] += y[i];}for(int i = 0; i < 5; i++){vector<int> p(n);for(int j = 0; j < n; j++){if(c[j] == i){p[j] += 1;}}reverse(q[i].begin(), q[i].end());vector<int> r = convolution(p, q[i]);for(int j = n - 1; j < 2 * n - 1; j++){res[j - n + 1] += r[j];}}int ans = *max_element(res.begin(), res.end());cout << ans << endl;}