結果
問題 |
No.3201 Corporate Synergy
|
ユーザー |
|
提出日時 | 2025-07-11 21:56:45 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 937 bytes |
コンパイル時間 | 3,694 ms |
コンパイル使用メモリ | 284,668 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-07-11 21:56:50 |
合計ジャッジ時間 | 3,810 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 WA * 12 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll =long long; #include<atcoder/maxflow> using namespace atcoder; const ll INF=1e15; void solve(){ ll N; cin>>N; mf_graph<ll> G(N+202); ll S=0; for(int i=0;i<N;i++){ ll X; cin>>X; if(X>=0){ S+=X; G.add_edge(i,N+1,X); } else{ G.add_edge(N,i,-X); } } ll M; cin>>M; for(int i=0;i<M;i++){ ll u,v; cin>>u>>v; u--;v--; G.add_edge(v,u,INF); } cin>>M; ll c=N+2; for(int i=0;i<M;i++){ ll u,v,w; cin>>u>>v>>w; u--;v--; S+=w; G.add_edge(c,N+1,w); G.add_edge(u,c,INF); G.add_edge(v,c,INF); c++; } cout<<S-G.flow(N,N+1)<<endl; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int T=1; // cin>>T; while(T--)solve(); }