結果
| 問題 |
No.3201 Corporate Synergy
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-11 22:03:30 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 959 bytes |
| コンパイル時間 | 3,423 ms |
| コンパイル使用メモリ | 285,052 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-07-11 22:03:36 |
| 合計ジャッジ時間 | 4,255 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#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(u,v,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<<endl;
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();
}