結果

問題 No.2330 Eat Slime
ユーザー houren
提出日時 2023-05-28 13:47:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,058 ms / 4,000 ms
コード長 1,160 bytes
コンパイル時間 3,275 ms
コンパイル使用メモリ 202,152 KB
実行使用メモリ 46,864 KB
最終ジャッジ日時 2024-12-26 21:56:12
合計ジャッジ時間 25,034 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

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