結果

問題 No.2330 Eat Slime
ユーザー hourenhouren
提出日時 2023-05-28 13:47:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 876 ms / 4,000 ms
コード長 1,160 bytes
コンパイル時間 2,755 ms
コンパイル使用メモリ 199,688 KB
実行使用メモリ 46,840 KB
最終ジャッジ日時 2023-08-27 08:28:46
合計ジャッジ時間 22,799 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 828 ms
38,080 KB
testcase_08 AC 422 ms
31,188 KB
testcase_09 AC 813 ms
32,888 KB
testcase_10 AC 107 ms
8,684 KB
testcase_11 AC 64 ms
5,088 KB
testcase_12 AC 826 ms
35,156 KB
testcase_13 AC 815 ms
38,004 KB
testcase_14 AC 128 ms
7,552 KB
testcase_15 AC 450 ms
30,696 KB
testcase_16 AC 799 ms
33,196 KB
testcase_17 AC 872 ms
46,608 KB
testcase_18 AC 871 ms
46,652 KB
testcase_19 AC 872 ms
46,648 KB
testcase_20 AC 870 ms
46,576 KB
testcase_21 AC 874 ms
46,560 KB
testcase_22 AC 870 ms
46,560 KB
testcase_23 AC 873 ms
46,788 KB
testcase_24 AC 870 ms
46,564 KB
testcase_25 AC 871 ms
46,576 KB
testcase_26 AC 873 ms
46,580 KB
testcase_27 AC 872 ms
46,836 KB
testcase_28 AC 875 ms
46,552 KB
testcase_29 AC 876 ms
46,840 KB
testcase_30 AC 871 ms
46,744 KB
testcase_31 AC 874 ms
46,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/convolution>
using namespace atcoder;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
constexpr ll INFLL = (1LL << 62), MOD = 998244353;
constexpr int INF = (1 << 30);

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m,x;
    cin >> n >> m >> x;
    vector<vector<ll>> c(5,vector<ll>(n,0)), b(5,vector<ll>(n,0));
    rep(i,n){
        int a;
        cin >> a;
        c[a-1][n-i-1] = 1;
    }
    rep(i,m){
        int p,q,r;
        cin >> p >> q >> r;
        p--; q--;
        b[q][p] += r;
    }
    vector<vector<ll>> d(5);
    rep(i,5){
        d[i] = convolution_ll(c[i],b[i]);
    }
    ll ans = n*x;
    rep(i,n){
        ll upd = x*(n-i-1);
        rep(j,5) upd += d[j][i];
        chmax(ans, upd);
    }
    cout << ans << '\n';
    return 0;
}
0