結果
問題 | No.2330 Eat Slime |
ユーザー |
![]() |
提出日時 | 2023-05-28 15:38:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,069 ms / 4,000 ms |
コード長 | 950 bytes |
コンパイル時間 | 4,798 ms |
コンパイル使用メモリ | 229,096 KB |
実行使用メモリ | 99,360 KB |
最終ジャッジ日時 | 2024-12-27 07:54:30 |
合計ジャッジ時間 | 29,954 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using namespace atcoder;typedef long long int ll;typedef pair<ll,ll> P;typedef vector<ll> VI;typedef vector<VI> VVI;#define REP(i,n) for(int i=0;i<(n);i++)#define ALL(v) v.begin(),v.end()template<typename T> bool chmax(T& x, const T& y){return (x<y)?(x=y,true):false;};template<typename T> bool chmin(T& x, const T& y){return (x>y)?(x=y,true):false;};constexpr ll MOD=998244353;constexpr ll INF=2e18;int main(){int n, m, x; cin >> n >> m >> x;VI c(n); REP(i,n) cin >> c[i], c[i]--;VI l(n*5,0), r(n*5,0);REP(i,n) l[i*5+c[i]]=1;int a, b, y;REP(i,m){cin >> a >> b >> y;a--, b--;r[a*5+b]+=y;}reverse(ALL(r));auto res=convolution_ll(l,r);int s=res.size();ll ans=n*x, z=0;for(int i=n*5-1;i<s;i+=5){chmax(ans,res[i]+z);z+=x;}cout << ans << endl;return 0;}