結果

問題 No.2330 Eat Slime
ユーザー dyktr_06dyktr_06
提出日時 2023-04-13 21:28:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 885 ms / 4,000 ms
コード長 1,154 bytes
コンパイル時間 4,712 ms
コンパイル使用メモリ 256,976 KB
実行使用メモリ 34,860 KB
最終ジャッジ日時 2024-04-17 23:58:58
合計ジャッジ時間 26,301 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 842 ms
28,700 KB
testcase_08 AC 427 ms
21,396 KB
testcase_09 AC 803 ms
23,944 KB
testcase_10 AC 108 ms
7,808 KB
testcase_11 AC 68 ms
6,944 KB
testcase_12 AC 842 ms
27,156 KB
testcase_13 AC 851 ms
27,848 KB
testcase_14 AC 257 ms
8,944 KB
testcase_15 AC 678 ms
22,872 KB
testcase_16 AC 787 ms
23,384 KB
testcase_17 AC 862 ms
34,560 KB
testcase_18 AC 876 ms
34,664 KB
testcase_19 AC 876 ms
34,744 KB
testcase_20 AC 878 ms
34,556 KB
testcase_21 AC 876 ms
34,688 KB
testcase_22 AC 873 ms
34,680 KB
testcase_23 AC 885 ms
34,684 KB
testcase_24 AC 874 ms
34,712 KB
testcase_25 AC 865 ms
34,860 KB
testcase_26 AC 861 ms
34,644 KB
testcase_27 AC 846 ms
34,684 KB
testcase_28 AC 852 ms
34,540 KB
testcase_29 AC 858 ms
34,552 KB
testcase_30 AC 864 ms
34,688 KB
testcase_31 AC 862 ms
34,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    long long 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<long long> y(m);
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i] >> y[i];
        a[i]--, b[i]--;
    }
    vector<long long> res(n + 1);
    for(long long i = 0; i <= n; i++){
        res[i] = x * i;
    }
    vector<vector<long long>> q(5, vector<long long>(n));
    for(int i = 0; i < m; i++){
        q[b[i]][a[i]] += y[i];
    }
    for(int i = 0; i < 5; i++){
        vector<long long> p(n);
        for(int j = 0; j < n; j++){
            if(c[j] == i){
                p[j] += 1;
            }
        }
        reverse(q[i].begin(), q[i].end());
        vector<long long> r = convolution_ll(p, q[i]);
        for(int j = n - 1; j < 2 * n - 1; j++){
            res[j - n + 1] += r[j];
        }
    }
    long long ans = *max_element(res.begin(), res.end());
    cout << ans << endl;
}
0